Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / amd64 / html / python / lib / profile-calibration.html
CommitLineData
920dae64
AT
1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<html>
3<head>
4<link rel="STYLESHEET" href="lib.css" type='text/css' />
5<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
6<link rel='start' href='../index.html' title='Python Documentation Index' />
7<link rel="first" href="lib.html" title='Python Library Reference' />
8<link rel='contents' href='contents.html' title="Contents" />
9<link rel='index' href='genindex.html' title='Index' />
10<link rel='last' href='about.html' title='About this document...' />
11<link rel='help' href='about.html' title='About this document...' />
12<link rel="next" href="node458.html" />
13<link rel="prev" href="profile-limits.html" />
14<link rel="parent" href="profile.html" />
15<link rel="next" href="node458.html" />
16<meta name='aesop' content='information' />
17<title>10.7 Calibration </title>
18</head>
19<body>
20<DIV CLASS="navigation">
21<div id='top-navigation-panel' xml:id='top-navigation-panel'>
22<table align="center" width="100%" cellpadding="0" cellspacing="2">
23<tr>
24<td class='online-navigation'><a rel="prev" title="10.6 Limitations"
25 href="profile-limits.html"><img src='../icons/previous.png'
26 border='0' height='32' alt='Previous Page' width='32' /></A></td>
27<td class='online-navigation'><a rel="parent" title="10. The Python Profiler"
28 href="profile.html"><img src='../icons/up.png'
29 border='0' height='32' alt='Up One Level' width='32' /></A></td>
30<td class='online-navigation'><a rel="next" title="10.8 Extensions "
31 href="node458.html"><img src='../icons/next.png'
32 border='0' height='32' alt='Next Page' width='32' /></A></td>
33<td align="center" width="100%">Python Library Reference</td>
34<td class='online-navigation'><a rel="contents" title="Table of Contents"
35 href="contents.html"><img src='../icons/contents.png'
36 border='0' height='32' alt='Contents' width='32' /></A></td>
37<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
38 border='0' height='32' alt='Module Index' width='32' /></a></td>
39<td class='online-navigation'><a rel="index" title="Index"
40 href="genindex.html"><img src='../icons/index.png'
41 border='0' height='32' alt='Index' width='32' /></A></td>
42</tr></table>
43<div class='online-navigation'>
44<b class="navlabel">Previous:</b>
45<a class="sectref" rel="prev" href="profile-limits.html">10.6 Limitations</A>
46<b class="navlabel">Up:</b>
47<a class="sectref" rel="parent" href="profile.html">10. The Python Profiler</A>
48<b class="navlabel">Next:</b>
49<a class="sectref" rel="next" href="node458.html">10.8 Extensions </A>
50</div>
51<hr /></div>
52</DIV>
53<!--End of Navigation Panel-->
54
55<H1><A NAME="SECTION0012700000000000000000"></A><A NAME="profile-calibration"></A>
56<BR>
5710.7 Calibration
58</H1>
59
60<P>
61The profiler subtracts a constant from each
62event handling time to compensate for the overhead of calling the time
63function, and socking away the results. By default, the constant is 0.
64The following procedure can
65be used to obtain a better constant for a given platform (see discussion
66in section Limitations above).
67
68<P>
69<div class="verbatim"><pre>
70import profile
71pr = profile.Profile()
72for i in range(5):
73 print pr.calibrate(10000)
74</pre></div>
75
76<P>
77The method executes the number of Python calls given by the argument,
78directly and again under the profiler, measuring the time for both.
79It then computes the hidden overhead per profiler event, and returns
80that as a float. For example, on an 800 MHz Pentium running
81Windows 2000, and using Python's time.clock() as the timer,
82the magical number is about 12.5e-6.
83
84<P>
85The object of this exercise is to get a fairly consistent result.
86If your computer is <em>very</em> fast, or your timer function has poor
87resolution, you might have to pass 100000, or even 1000000, to get
88consistent results.
89
90<P>
91When you have a consistent answer,
92there are three ways you can use it:<A NAME="tex2html52"
93 HREF="#foot46353"><SUP>10.3</SUP></A>
94<P>
95<div class="verbatim"><pre>
96import profile
97
98# 1. Apply computed bias to all Profile instances created hereafter.
99profile.Profile.bias = your_computed_bias
100
101# 2. Apply computed bias to a specific Profile instance.
102pr = profile.Profile()
103pr.bias = your_computed_bias
104
105# 3. Specify computed bias in instance constructor.
106pr = profile.Profile(bias=your_computed_bias)
107</pre></div>
108
109<P>
110If you have a choice, you are better off choosing a smaller constant, and
111then your results will ``less often'' show up as negative in profile
112statistics.
113
114<P>
115<BR><HR><H4>Footnotes</H4>
116<DL>
117<DT><A NAME="foot46353">... it:</A><A
118 href="profile-calibration.html#tex2html52"><SUP>10.3</SUP></A></DT>
119<DD>Prior to Python 2.2, it
120 was necessary to edit the profiler source code to embed the bias as
121 a literal number. You still can, but that method is no longer
122 described, because no longer needed.
123
124</DD>
125</DL>
126<DIV CLASS="navigation">
127<div class='online-navigation'>
128<p></p><hr />
129<table align="center" width="100%" cellpadding="0" cellspacing="2">
130<tr>
131<td class='online-navigation'><a rel="prev" title="10.6 Limitations"
132 href="profile-limits.html"><img src='../icons/previous.png'
133 border='0' height='32' alt='Previous Page' width='32' /></A></td>
134<td class='online-navigation'><a rel="parent" title="10. The Python Profiler"
135 href="profile.html"><img src='../icons/up.png'
136 border='0' height='32' alt='Up One Level' width='32' /></A></td>
137<td class='online-navigation'><a rel="next" title="10.8 Extensions "
138 href="node458.html"><img src='../icons/next.png'
139 border='0' height='32' alt='Next Page' width='32' /></A></td>
140<td align="center" width="100%">Python Library Reference</td>
141<td class='online-navigation'><a rel="contents" title="Table of Contents"
142 href="contents.html"><img src='../icons/contents.png'
143 border='0' height='32' alt='Contents' width='32' /></A></td>
144<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
145 border='0' height='32' alt='Module Index' width='32' /></a></td>
146<td class='online-navigation'><a rel="index" title="Index"
147 href="genindex.html"><img src='../icons/index.png'
148 border='0' height='32' alt='Index' width='32' /></A></td>
149</tr></table>
150<div class='online-navigation'>
151<b class="navlabel">Previous:</b>
152<a class="sectref" rel="prev" href="profile-limits.html">10.6 Limitations</A>
153<b class="navlabel">Up:</b>
154<a class="sectref" rel="parent" href="profile.html">10. The Python Profiler</A>
155<b class="navlabel">Next:</b>
156<a class="sectref" rel="next" href="node458.html">10.8 Extensions </A>
157</div>
158</div>
159<hr />
160<span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span>
161</DIV>
162<!--End of Navigation Panel-->
163<ADDRESS>
164See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
165</ADDRESS>
166</BODY>
167</HTML>