Re: Precise timings ?



On Tue, 30 Aug 2005 13:36:57 -0400, Madhusudan Singh <spammers-go-here@xxxxxxxxxxxx> wrote:

>Hi
>
>I am using time.clock() to get the current time of the processor in seconds.
>For my application, I need really high resolution but currently seem to be
>limited to 0.01 second. Is there a way to specify the resolution (say 1-10
>microseconds) ? My processor is a 1.4 MHz Intel processor. Surely, it
^--G?
>should be able to report times a few (or at least 10) microseconds apart.
>
windows or unix? time.time and time.clock seem to reverse roles as best-resolution
time sources depending on which platform.

If you have a pentium with a rdtsc instruction, you can write an extension module
in c to get at it. In C on a 300mhz p2 I got down to 23ns minimum delta between calls, IIRC.
But even then I was subject to the small probability of an interrupt during my timing loop,
and there are many normally going on, so the longer the interval you are timing the greater
the probability that an interrupt will occur within it (assuming random independence, which is
also not necessarily true). This is why timing frameworks generally either average brute force
or discard outlier timings and average, or return best-of. All these have different error
properties, and depend on lots of stuff.

I'm wondering whats your application is. Maybe you need a real-time OS?

Regards,
Bengt Richter
.



Relevant Pages

  • Re: Precise timings ?
    ... so the longer the interval you are timing the greater ... > the probability that an interrupt will occur within it (assuming random ... > frameworks generally either average brute force or discard outlier timings ...
    (comp.lang.python)
  • Re: [DCC] Protokollfrage
    ... Timing steht, darf es aber keine anderen Interrupts oder Zeiten ... gesteuert wird und der Interrupt nur die Vorbereitung macht, ... Effektiv ist es, das Timing von der Hardware zu machen. ... Ebene in Assembler zu schreiben. ...
    (de.rec.modelle.bahn)
  • Re: Interrupts
    ... timing something like an interrupt in the ... emulator is *completely* worthless. ... have a nice hardware signal with which you can measure timing. ...
    (microsoft.public.windowsce.embedded.vc)
  • [PATCH -rt] compile error on interrupt off timing
    ... I found a compile error with lockdep off, and interrupt off timing on. ... and I also fixed the ifdef comments. ...
    (Linux-Kernel)