measuring runtimes

Chris Torek torek at elf.ee.lbl.gov
Fri Feb 22 02:35:04 AEST 1991


In article <2435 at alf.informatik.uni-kiel.dbp.de> rn at informatik.uni-kiel.dbp.de
(Rilo Nauman) writes:
>I need to measure runtimes of functions and moduls of
>C-programs under sun-OS.4.1 on a sparc station 1.
>I'm looking for a timer with quite a high resolution.

The C language provides nothing along these lines.  (Perhaps you should
have posted to comp.sys.sun.  I have redirected followups there.)

>Till now, I'm using system-calls to clock() and
>setitimer()-/ getitimer()-calls but the best resolution
>I can get is about 16.6 ms (60 Hz), (10 ms ).

Both SunOS and Sun hardware are generally uncooperative in obtaining
precise timings.  There are, however, some interesting tricks that can
be used:

 1. An external clock that plugs into the CPU board.  A company located
    somewhere in Oakland, CA makes these for (at least) the Sun-3; it
    goes in the DES chip socket.  With a little work you can map the
    device into user space and obtain quite good timings.

 2. The SparcStation-1 has a little green LED on it.  This is enabled
    in software, and it is possible to turn it on and off in kernel
    code.  Attaching an external monitor (an oscilloscope will do) will
    let you time sections of code.

As always, you must be careful when timing small sections of code since
the code added to get the times affects the results.
-- 
In-Real-Life: Chris Torek, Lawrence Berkeley Lab EE div (+1 415 486 5427)
Berkeley, CA		Domain:	torek at ee.lbl.gov



More information about the Comp.lang.c mailing list