📄 http:^^www.cs.utexas.edu^users^markj^zentimer.html
字号:
MIME-Version: 1.0
Server: CERN/3.0
Date: Monday, 06-Jan-97 22:49:07 GMT
Content-Type: text/html
Content-Length: 3653
Last-Modified: Wednesday, 04-Oct-95 21:09:15 GMT
<HTML><HEAD><title>Zen Timer Code</title></HEAD><BODY><h1>Zen Timer Code</h1>I have implemented a class library in C++ that uses an undocumentedfeature of the <a href="http://www.intel.com">Intel(tm)</a>Pentium(tm) processor to very precisely time your executable code forpurposes of profiling. Information about this feature and otherundocumented Pentium features is available<a href="http://x86.metronet.com">here.</a> Simultaneous timing of anynumber of routines is supported, as well as suspending and resumingthe timing at any point during the timed interval.<p>This code was inspired by Michael Abrash's excellent book <ahref="http://www.coriolis.com/devclub/pc_sys.htm#zen_codeop"> Zen of CodeOptimization</a>.<p>My code works by accessing a 64-bit register in the Intel Pentiumprocessor that is incremented on every clock cycle. On a 100 MHZPentium, this gives a clock resolution of 10 nanoseconds (one cycle),and a maximum time interval of about 5,800 years.<p>This code keeps track of the minimum, maximum, and average timeintervals for the pieces of code that you are profiling. In addition,it is possible to specify a dribble file that will record everyinterval of time measured.<p>This code has been implemented and tested on a Pentium running Linux1.2.13 with gcc 2.7.0 and the GNU assembler versioncygnus/linux-2.5.2l.15. To use this code, you must patch yourassembler with the supplied patch file.<p>Click <a href="src/zentimer/zentimer.h">here</a> to download a copy of theZen timer code.<p>Click <a href="src/zentimer/patch-for-gas-for-undocumented-opcodes">here</a> todownload a copy of the patch file for the GNU assembler.<p>Click <a href="src/zentimer/test-timer.cc">here</a> to download a test programthat makes use of the timer code.<p>I also developed two useful utilities for use with the Zen Timer.The first converts a time dribble file into an ascii (humanreadable) version.<p>Click <a href="src/zentimer/time2ascii.cc">here</a> to download the time2asciicode.<p>The second converts a time dribble file into an ascii histogram file(suitable for use with a spreadsheet for example).<p>click <a href="src/zentimer/time2histo.cc">here</a> to download the time2histocode.<p><h3>An important note on accounting for the overhead caused by thetimer itself</h3><p>The zen timer introduces some overhead into every timed interval byvirtue of it having to execute a few instructions to do the profiling.In an attempt to account for this overhead, I have defined some macrosin the file zentimer.h that have overhead values that work for mysystem.<p>I have, however, found that there are a number of different factorsthat can affect the overhead introduced by running the timer. Inparticular, I suggest that you not use x-windows while using the timeras it seems to add particularly unpredictable overheads to the timingresults. Also, different disks, or a different system board can causethese overheads to change. You should try running the timer on yoursystem with my small test program, and see if you get an averageinterval of 0 cycles. If not, adjust the overhead macros inzentimer.h until you do.</body><HR><center><ADDRESS> Last updated 10/03/95<br> <strong>Mark Johnstone.</strong><br> Any <a href="mailto:markj@cs.utexas.edu"> suggestions, comments welcome</a>.<br> <a href="http::/www.cs.utexas.edu">Department of Computer Sciences</a><br> at <a href="http::/www.utexas.edu"> UT Austin </a><p> Click to send e-mail to <a href="mailto:markj@cs.utexas.edu"> Mark Johnstone </a></ADDRESS> </html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -