Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v9 / html / python / lib / node458.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="lib.css" type='text/css' />
<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
<link rel='start' href='../index.html' title='Python Documentation Index' />
<link rel="first" href="lib.html" title='Python Library Reference' />
<link rel='contents' href='contents.html' title="Contents" />
<link rel='index' href='genindex.html' title='Index' />
<link rel='last' href='about.html' title='About this document...' />
<link rel='help' href='about.html' title='About this document...' />
<link rel="next" href="module-hotshot.html" />
<link rel="prev" href="profile-calibration.html" />
<link rel="parent" href="profile.html" />
<link rel="next" href="module-hotshot.html" />
<meta name='aesop' content='information' />
<title>10.8 Extensions -- Deriving Better Profilers</title>
</head>
<body>
<DIV CLASS="navigation">
<div id='top-navigation-panel' xml:id='top-navigation-panel'>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="10.7 Calibration"
href="profile-calibration.html"><img src='../icons/previous.png'
border='0' height='32' alt='Previous Page' width='32' /></A></td>
<td class='online-navigation'><a rel="parent" title="10. The Python Profiler"
href="profile.html"><img src='../icons/up.png'
border='0' height='32' alt='Up One Level' width='32' /></A></td>
<td class='online-navigation'><a rel="next" title="10.9 hotshot "
href="module-hotshot.html"><img src='../icons/next.png'
border='0' height='32' alt='Next Page' width='32' /></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
href="contents.html"><img src='../icons/contents.png'
border='0' height='32' alt='Contents' width='32' /></A></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
border='0' height='32' alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
href="genindex.html"><img src='../icons/index.png'
border='0' height='32' alt='Index' width='32' /></A></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="profile-calibration.html">10.7 Calibration</A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="profile.html">10. The Python Profiler</A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="module-hotshot.html">10.9 hotshot </A>
</div>
<hr /></div>
</DIV>
<!--End of Navigation Panel-->
<H1><A NAME="SECTION0012800000000000000000">
10.8 Extensions -- Deriving Better Profilers</A>
</H1>
<A NAME="Profiler_Extensions"></A>
<P>
The <tt class="class">Profile</tt> class of module <tt class="module">profile</tt> was written so that
derived classes could be developed to extend the profiler. The details
are not described here, as doing this successfully requires an expert
understanding of how the <tt class="class">Profile</tt> class works internally. Study
the source code of module <tt class="module">profile</tt> carefully if you want to
pursue this.
<P>
If all you want to do is change how current time is determined (for
example, to force use of wall-clock time or elapsed process time),
pass the timing function you want to the <tt class="class">Profile</tt> class
constructor:
<P>
<div class="verbatim"><pre>
pr = profile.Profile(your_time_func)
</pre></div>
<P>
The resulting profiler will then call <code>your_time_func()</code>.
The function should return a single number, or a list of
numbers whose sum is the current time (like what <tt class="function">os.times()</tt>
returns). If the function returns a single time number, or the list of
returned numbers has length 2, then you will get an especially fast
version of the dispatch routine.
<P>
Be warned that you should calibrate the profiler class for the
timer function that you choose. For most machines, a timer that
returns a lone integer value will provide the best results in terms of
low overhead during profiling. (<tt class="function">os.times()</tt> is
<em>pretty</em> bad, as it returns a tuple of floating point values). If
you want to substitute a better timer in the cleanest fashion,
derive a class and hardwire a replacement dispatch method that best
handles your timer call, along with the appropriate calibration
constant.
<DIV CLASS="navigation">
<div class='online-navigation'>
<p></p><hr />
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="10.7 Calibration"
href="profile-calibration.html"><img src='../icons/previous.png'
border='0' height='32' alt='Previous Page' width='32' /></A></td>
<td class='online-navigation'><a rel="parent" title="10. The Python Profiler"
href="profile.html"><img src='../icons/up.png'
border='0' height='32' alt='Up One Level' width='32' /></A></td>
<td class='online-navigation'><a rel="next" title="10.9 hotshot "
href="module-hotshot.html"><img src='../icons/next.png'
border='0' height='32' alt='Next Page' width='32' /></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
href="contents.html"><img src='../icons/contents.png'
border='0' height='32' alt='Contents' width='32' /></A></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
border='0' height='32' alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
href="genindex.html"><img src='../icons/index.png'
border='0' height='32' alt='Index' width='32' /></A></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="profile-calibration.html">10.7 Calibration</A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="profile.html">10. The Python Profiler</A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="module-hotshot.html">10.9 hotshot </A>
</div>
</div>
<hr />
<span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span>
</DIV>
<!--End of Navigation Panel-->
<ADDRESS>
See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
</ADDRESS>
</BODY>
</HTML>