123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207 |
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
- <html>
- <!-- Created on December 10, 2012 by texi2html 1.82
- texi2html was written by:
- Lionel Cons <[email protected]> (original author)
- Karl Berry <[email protected]>
- Olaf Bachmann <[email protected]>
- and many others.
- Maintained by: Many creative people.
- Send bugs and suggestions to <[email protected]>
- -->
- <head>
- <title>avram - a virtual machine code interpreter: 3.7 Profiling</title>
- <meta name="description" content="avram - a virtual machine code interpreter: 3.7 Profiling">
- <meta name="keywords" content="avram - a virtual machine code interpreter: 3.7 Profiling">
- <meta name="resource-type" content="document">
- <meta name="distribution" content="global">
- <meta name="Generator" content="texi2html 1.82">
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <style type="text/css">
- <!--
- a.summary-letter {text-decoration: none}
- blockquote.smallquotation {font-size: smaller}
- pre.display {font-family: serif}
- pre.format {font-family: serif}
- pre.menu-comment {font-family: serif}
- pre.menu-preformatted {font-family: serif}
- pre.smalldisplay {font-family: serif; font-size: smaller}
- pre.smallexample {font-size: smaller}
- pre.smallformat {font-family: serif; font-size: smaller}
- pre.smalllisp {font-size: smaller}
- span.roman {font-family:serif; font-weight:normal;}
- span.sansserif {font-family:sans-serif; font-weight:normal;}
- ul.toc {list-style: none}
- -->
- </style>
- </head>
- <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
- <a name="Profiling"></a>
- <table cellpadding="1" cellspacing="1" border="0">
- <tr><td valign="middle" align="left">[<a href="Error-Reporting.html#Error-Reporting" title="Previous section in reading order"> < </a>]</td>
- <td valign="middle" align="left">[<a href="Emulation-Primitives.html#Emulation-Primitives" title="Next section in reading order"> > </a>]</td>
- <td valign="middle" align="left"> </td>
- <td valign="middle" align="left">[<a href="Library-Reference.html#Library-Reference" title="Beginning of this chapter or previous chapter"> << </a>]</td>
- <td valign="middle" align="left">[<a href="Library-Reference.html#Library-Reference" title="Up section"> Up </a>]</td>
- <td valign="middle" align="left">[<a href="Character-Table.html#Character-Table" title="Next chapter"> >> </a>]</td>
- <td valign="middle" align="left"> </td>
- <td valign="middle" align="left"> </td>
- <td valign="middle" align="left"> </td>
- <td valign="middle" align="left"> </td>
- <td valign="middle" align="left">[<a href="avram.html#Top" title="Cover (top) of document">Top</a>]</td>
- <td valign="middle" align="left">[<a href="avram_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
- <td valign="middle" align="left">[<a href="Function-Index.html#Function-Index" title="Index">Index</a>]</td>
- <td valign="middle" align="left">[<a href="avram_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
- </tr></table>
- <hr size="1">
- <a name="Profiling-1"></a>
- <h2 class="section">3.7 Profiling</h2>
- <a name="index-profile_002eh"></a>
- <p>The functions declared in ‘<tt>profile.h</tt>’ can be used for constructing
- and writing tables of run time statistics such as those mentioned in
- <a href="Files.html#Files">Files</a>, and <a href="Profile.html#Profile">Profile</a>. These functions maintain a database of
- structures, each recording the statistics for a particular virtual code
- fragment.
- </p>
- <p>Each structure in the database is identified by a unique key, which must
- be a list representing a character string. A pointer to such a structure
- <a name="index-score"></a>
- is declared to be of type <code>score</code>. For the most part, the data
- structure should be regarded as opaque by a client program, except for a
- field <code>reductions</code> of type <code>counter</code>, which may be modified
- arbitrarily by the client.
- </p>
- <p>The way these operations are used in the course of evaluating virtual
- code applications containing profile annotations is to add a structure
- to the database each time a new profiled code fragment is encountered,
- using the annotation as its key, and to increment the <code>reductions</code>
- <a name="index-annotations-1"></a>
- of the structure each time any constituent of the code gets a quantum of
- work done on it. Other ways of using these operations are left to the
- developer’s discretion.
- </p>
- <dl>
- <dt><a name="index-avm_005fentries"></a><u>Function:</u> score <b>avm_entries</b><i> (list <var>team</var>, list *<var>message</var>, int *<var>fault</var>)</i></dt>
- <dd><p>This function retrieves or creates a data base entry given its key. The
- parameters have these interpretations.
- </p>
- <dl compact="compact">
- <dt> <code><var>team</var></code></dt>
- <dd><p>is a list representing a character string that uniquely identifies the
- database entry to be retrieved or created.
- </p></dd>
- <dt> <code><var>message</var></code></dt>
- <dd><p>is the address of a list known to the caller, which will be assigned a
- list representing an error message if any error occurs in the course of
- searching the database or creating a new entry.
- </p></dd>
- <dt> <code><var>fault</var></code></dt>
- <dd><p>is the address of an integer that will be set to a non-zero value if any
- error is caused by this function.
- </p></dd>
- </dl>
- <p>The pointer returned by this function is the address of the record whose
- key is given by the <code><var>team</var></code> parameter. If such a record is
- already in the database, its address is returned, but otherwise a new
- one is created whose address is then returned. The <code>reductions</code>
- field of a newly created entry will be zero.
- </p>
- <p>In the course of searching the database, the <code>avm_compare</code>
- function is used, so the associated lists may be modified as noted in
- <a href="Comparison.html#Comparison">Comparison</a>. It is not necessary for a client to include the header
- file ‘<tt>compare.h</tt>’ or to call <code>avm_initialize_compare</code> in order
- to use the profile operations, because they are done automatically.
- </p>
- <p>If an error message is assigned to the list referenced by
- <code><var>message</var></code>, the integer referenced by <code><var>fault</var></code> will
- be set to a non-zero value. The form of the error message will be a list
- in which each item is a list of character representations as per
- <a href="Character-Table.html#Character-Table">Character Table</a>. It is the responsibility of the caller to dispose
- of the error message. Currently the only possible error is a memory
- overflow, which in this case is non-fatal.
- </p></dd></dl>
- <dl>
- <dt><a name="index-avm_005ftally"></a><u>Function:</u> void <b>avm_tally</b><i> (char *<var>filename</var>)</i></dt>
- <dd><p>This function makes a table of the results stored in the data base built
- by the <code>avm_entries</code> function. The argument is the address of a
- null terminated character string containing the name of the file in
- which the results will be written. A file is opened and the table is
- written in a self explanatory text format, with columns labeled
- “reductions” and “invocations” among others. The latter contains the
- number of times the associated key was accessed through
- <code>avm_entries</code>.
- </p>
- <p>The data written to the file should be taken with a grain of salt. It
- is computed using native integer and floating point arithmetic, with no
- checks made for overflow or roundoff error, and no guarantee of cross
- <a name="index-reductions"></a>
- platform portability. The number of “reductions” means whatever the
- developer of the client program wants it to mean.
- </p>
- <p>The following error messages are possible with this function, which will
- be written to standard error. None of them is fatal.
- <a name="index-can_0027t-write-5"></a>
- <a name="index-can_0027t-close-2"></a>
- <a name="index-invalid-profile-identifier-1"></a>
- </p>
- <ul>
- <li> <code><var>program-name</var>: can't write <var>filename</var></code>
- </li><li> <code><var>program-name</var>: can't write to <var>filename</var></code>
- </li><li> <code><var>program-name</var>: can't close <var>filename</var></code>
- </li><li> <code><var>program-name</var>: invalid profile identifier</code>
- </li></ul>
- <p>The last message is reported if any record in the database has a key
- that is not a list of valid character representations. The others are
- <a name="index-strerror-5"></a>
- accompanied by an explanation from the standard <code>strerror</code> function
- if possible.
- </p></dd></dl>
- <dl>
- <dt><a name="index-avm_005finitialize_005fprofile"></a><u>Function:</u> void <b>avm_initialize_profile</b><i> ()</i></dt>
- <dd><p>This function should be called before any of the other functions in this
- section in order to initialize the data base. Results are undefined if
- it is not called first.
- </p></dd></dl>
- <dl>
- <dt><a name="index-avm_005fcount_005fprofile"></a><u>Function:</u> void <b>avm_count_profile</b><i> ()</i></dt>
- <dd><p>This function can be called after the other functions in this section as
- a way of detecting memory leaks. If any storage remains unreclaimed that
- was created by the functions in this section, a warning message is
- written to standard error. If the <code>avm_count_lists</code> function is
- being used by the client program, it should be called after this one.
- </p></dd></dl>
- <hr size="1">
- <table cellpadding="1" cellspacing="1" border="0">
- <tr><td valign="middle" align="left">[<a href="Error-Reporting.html#Error-Reporting" title="Previous section in reading order"> < </a>]</td>
- <td valign="middle" align="left">[<a href="Emulation-Primitives.html#Emulation-Primitives" title="Next section in reading order"> > </a>]</td>
- <td valign="middle" align="left"> </td>
- <td valign="middle" align="left">[<a href="Library-Reference.html#Library-Reference" title="Beginning of this chapter or previous chapter"> << </a>]</td>
- <td valign="middle" align="left">[<a href="Library-Reference.html#Library-Reference" title="Up section"> Up </a>]</td>
- <td valign="middle" align="left">[<a href="Character-Table.html#Character-Table" title="Next chapter"> >> </a>]</td>
- <td valign="middle" align="left"> </td>
- <td valign="middle" align="left"> </td>
- <td valign="middle" align="left"> </td>
- <td valign="middle" align="left"> </td>
- <td valign="middle" align="left">[<a href="avram.html#Top" title="Cover (top) of document">Top</a>]</td>
- <td valign="middle" align="left">[<a href="avram_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
- <td valign="middle" align="left">[<a href="Function-Index.html#Function-Index" title="Index">Index</a>]</td>
- <td valign="middle" align="left">[<a href="avram_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
- </tr></table>
- <p>
- <font size="-1">
- This document was generated on <i>December 10, 2012</i> using <a href="http://www.nongnu.org/texi2html/"><i>texi2html 1.82</i></a>.
- </font>
- <br>
- </p>
- </body>
- </html>
|