[Issue 13433] Request: Clock.currTime option to use CLOCK_REALTIME_COARSE / CLOCK_REALTIME_FAST

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sat Oct 4 03:53:47 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=13433

--- Comment #8 from Marco Leise <Marco.Leise at gmx.de> ---
I just ran a test:

void main(string[] args)
{
    while (true)
    {
        timespec time;
        clock_gettime(CLOCK_REALTIME_COARSE, &time);
        printf(":%03ld ms\n", time.tv_nsec / 1_000_000);
    }
}

My kernel has CONFIG_HZ=1000 and CONFIG_NO_HZ=y (tick-less). The coarse timer
shows a precise 1 ms precision. What's more, compared to the fine grained
timer, it is ~100 times faster (!) [compiled with DMD and release options,
Core2Duo 2Ghz]:

1024 ms for 100,000,000 calls to the coarse real-time clock.
1059 ms for   1,000,000 calls to the regular real-time clock.

If your code benefits much from the 100 times faster time queries, millisecond
precision is a good trade off.

--


More information about the Digitalmars-d-bugs mailing list