C99 and GMP tuning

Hans Åberg haberg-1 at telia.com
Mon Apr 9 21:56:07 UTC 2018


> On 9 Apr 2018, at 23:30, Vincent Lefevre <vincent at vinc17.net> wrote:
> 
> On 2018-04-09 22:14:50 +0200, Hans Åberg wrote:
>> This page [1] says that POSIX clock_gettime [2] with clock id
>> CLOCK_PROCESS_CPUTIME_ID offers better resolution than clock.
> 
> Under Linux, clock is based on clock_gettime with
> CLOCK_PROCESS_CPUTIME_ID, but the result is in microseconds
> only because CLOCKS_PER_SEC is 1000000 as required by XSI.
> 
> The practical accuracy of clock_gettime with
> CLOCK_PROCESS_CPUTIME_ID seems about 0.4 microsecond
> (at least on my machine), so that there isn't much difference
> between both.
> 
> The advantage of getrusage is that you can choose to consider
> the user time only.
> 
> I'm attaching a program to compare clock related functions
> I wrote some time ago.

On MacOS 10.13.4, I get, with your program, CLOCK_PROCESS_CPUTIME_I resolution 1000 ns, the same as for 'clock', and about the same number of calls 1 M/s, but CLOCK_THREAD_CPUTIME_ID has resolution 1 ns, but only slightly more calls.




More information about the gmp-discuss mailing list