Accurate time measurements on SS1+, 3/260, etc.

Jim Kohli mrsvr!gemed.kohli at uwm.edu
Sun Dec 30 12:04:00 AEST 1990


In article <915 at brchh104.bnr.ca>, rcomr at koel.co.rmit.oz.au (Mark
Rawling) writes:
<I am trying to make some accurate timing measurements of function call
<times (user times only). It is intended to have the code monitor itself
<something like :-
<
<    ...
<    get_current_time(&start);
<    function_to_be_timed();
<    get_current_time(&stop);
<    function_time = stop - start;
<    ...
<
<The problem is that getrusage is limited to 10mS resolution (on the SS1+,
<and worse elsewhere). Thus the rusage.ru_utime.tv_usec field is always
<nn0000 micro-secs. The only thing I can see that is potentially better
<than this is "time (3V)" which returns a milliseconds field. But of
<course, this is real time and would require running single user, disabling
<interrupts, etc.

It is not unusual to do something like this:

    ...
    get_current_time(&start);
	for( i=0 ; i<1000 ; i++ ) function_to_be_timed();
    get_current_time(&stop);
    function_time = (float)(stop - start)/1000.0;
    ...

Jim Kohli
GE Medical



More information about the Comp.sys.sun mailing list