C99 and GMP tuning

Vincent Lefevre vincent at vinc17.net
Tue Apr 10 14:09:10 UTC 2018


On 2018-04-10 15:55:10 +0200, Hans Åberg wrote:
> 
> 
> > On 10 Apr 2018, at 15:43, Vincent Lefevre <vincent at vinc17.net> wrote:
> > 
> > On 2018-04-10 15:08:43 +0200, Hans Åberg wrote:
> >> On MacOS 10.13.4, I get:
> >> 
> >> $ ./clock-times clock 1.000000001
> >> Clock units per second: 1000000
> >> Number of calls: 1171029 (1.000002 s)
> >> Number of calls: 2347811 (2.000001 s)
> >> Number of calls: 3516471 (3 s)
> >> 
> >> $ ./clock-times getrusage 1.000000001
> >> Number of calls: 2350134 (1.000001 s)
> >> Number of calls: 4706277 (2.000001 s)
> >> Number of calls: 7059820 (3 s)
> >> 
> >> $ ./clock-times CLOCK_PROCESS_CPUTIME_ID 1.000000001
> >> Clock resolution (id 12 [CLOCK_PROCESS_CPUTIME_ID]): 1000 ns
> >> Number of calls: 1163761 (1.000001 s)
> >> Number of calls: 2330127 (2.000002 s)
> >> Number of calls: 3492651 (3 s)
> > 
> > About these, you should recompile clock-times with -DNSEC=20
> > (or perhaps more) to see at which frequency you get ".000002"
> > instead of ".000001". It is probable that these 3 functions
> > are actually about the same there.
> 
> Then I get, leaving to you to interpret it,

Concerning clock and CLOCK_PROCESS_CPUTIME_ID, there are about
1 million calls per second. This might explain the .000002 for
these cases (the + .000001 would basically correspond to the
execution time of the function), but this depends very much on
the internal implementation.

Note that getrusage looks like faster, but probably just because
it only includes the user time here, not the system time, which
is probably important here. The code could be improved to add
getrusage2, using the combined user + system times.

> though CLOCK_THREAD_CPUTIME_ID seems to have the best resolution.

Yes.

-- 
Vincent Lefèvre <vincent at vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)


More information about the gmp-discuss mailing list