[comp.lang.c] measuring runtimes

rn@informatik.uni-kiel.dbp.de (Rilo Nauman) (02/21/91)

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.
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 ).
Does anyone know a possibility to get a better resolution
of the runtime ?
By the way, does anyone exactly know what kind of runtime
is measured by calls to clock() and getitimer(ITIMER-VIRTUAL,
ITIMER_PROF) ?
The manual isn't very precise at this point!

Any hints and suggestions are recommended !

Please respond to
rn@informatik.uni-kiel.dbp.de

Rilo Naumann

torek@elf.ee.lbl.gov (Chris Torek) (02/21/91)

In article <2435@alf.informatik.uni-kiel.dbp.de> rn@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@ee.lbl.gov