On Sun, 2010-05-23 at 17:02 +0800, tenz...@iinet.net.au wrote:
> I'm seeking a preferably citeable reference to the amount of error
> in the returned result from a Time() command. I want to be
> able to quote the level of error in timing the execution speed
> of my project.

"man time" gives the answer.

> These statistics consist of (i) the elapsed real time
> between invocation and termination, (ii) the user CPU
> time (the sum of the tms_utime and tms_cutime values
> in a struct tms as returned by times(2)), and (iii)
> the  system CPU  time  (the  sum of the tms_stime and
> tms_cstime values in a struct tms as returned by times(2)).

"man 2 times" says that these data types are clock_t and

> times()  returns  the  number of clock ticks that have
> elapsed since an arbitrary point in the past.

and

> The number of clock ticks per second can be obtained
> using: sysconf(_SC_CLK_TCK);

so

#include <stdio.h>
#include <unistd.h>
int main(void) {
    printf("_SC_CLK_TCK is %ld\n", sysconf(_SC_CLK_TCK));
    return 0;
}

which says for my platform

_SC_CLK_TCK is 100

Now the measuring precision may not match the reporting precision. But
the quantum of your kernel's task scheduler is somewhere between 100 and
1000 (see the CONFIG_HZ kernel compilation flag), so it is safe to say
that the reported precision of the tms API is the source of maximum
error.

If you need more precise runtimes and more details of consumed resources
then see the TASKSSTATS system. The documentation which accompanies the
kernel source contains sample code which will print all process exits
and the resources used to a high precision.

You also have control of the error. If you are lacking precision, then
give the program a task which makes it run for 10x or 100x longer.

As for citable you've got Buckley's. Shove the argument and program
above into an appendix and cross-reference it as you would any other
minor experiment or incidental proof. In general, these intermediate
results don't contribute to word count, but do check the local policy.

-- 
Glen Turner
<http://www.gdt.id.au/~gdt/>

-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to