C99 and GMP tuning

Hans Åberg haberg-1 at telia.com
Tue Apr 10 13:55:10 UTC 2018



> 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, though CLOCK_THREAD_CPUTIME_ID seems to have the best resolution.

$ ./clock-times clock 1.000000001
Clock units per second: 1000000
Number of calls: 1141841 (1.000002 s)
Number of calls: 2274871 (2.000001 s)
Number of calls: 3416874 (3.000001 s)
Number of calls: 4560071 (4.000001 s)
Number of calls: 5702343 (5.000001 s)
Number of calls: 6834493 (6.000001 s)
Number of calls: 7980325 (7.000001 s)
Number of calls: 9114575 (8.000001 s)
Number of calls: 10250035 (9.000001 s)
Number of calls: 11377271 (10.000002 s)
Number of calls: 12513012 (11.000001 s)
Number of calls: 13657424 (12.000002 s)
Number of calls: 14803279 (13.000001 s)
Number of calls: 15945704 (14.000001 s)
Number of calls: 17087673 (15.000001 s)
Number of calls: 18223931 (16.000001 s)
Number of calls: 19368513 (17.000001 s)
Number of calls: 20511888 (18.000002 s)
Number of calls: 21656057 (19.000001 s)
Number of calls: 22797732 (20.000001 s)

$ ./clock-times getrusage 1.000000001
Number of calls: 2329595 (1.000001 s)
Number of calls: 4665510 (2.000001 s)
Number of calls: 7004691 (3.000001 s)
Number of calls: 9343412 (4.000001 s)
Number of calls: 11680585 (5.000001 s)
Number of calls: 14007024 (6.000001 s)
Number of calls: 16349473 (7.000001 s)
Number of calls: 18677785 (8.000001 s)
Number of calls: 21019628 (9.000001 s)
Number of calls: 23355158 (10.000001 s)
Number of calls: 25695778 (11.000001 s)
Number of calls: 28035138 (12.000001 s)
Number of calls: 30376333 (13.000001 s)
Number of calls: 32712376 (14.000001 s)
Number of calls: 35048748 (15.000001 s)
Number of calls: 37253382 (16.000001 s)
Number of calls: 39546112 (17.000001 s)
Number of calls: 41878110 (18.000001 s)
Number of calls: 44214616 (19.000001 s)
Number of calls: 46538565 (20 s)

$ ./clock-times CLOCK_PROCESS_CPUTIME_ID 1.000000001
Clock resolution (id 12 [CLOCK_PROCESS_CPUTIME_ID]): 1000 ns
Number of calls: 1162288 (1.000001 s)
Number of calls: 2338304 (2.000001 s)
Number of calls: 3502511 (3.000001 s)
Number of calls: 4668127 (4.000002 s)
Number of calls: 5809303 (5.000002 s)
Number of calls: 6948530 (6.000001 s)
Number of calls: 8109811 (7.000001 s)
Number of calls: 9270723 (8.000001 s)
Number of calls: 10427406 (9.000001 s)
Number of calls: 11571381 (10.000001 s)
Number of calls: 12734442 (11.000001 s)
Number of calls: 13902924 (12.000001 s)
Number of calls: 15076956 (13.000002 s)
Number of calls: 16238750 (14.000002 s)
Number of calls: 17409414 (15.000001 s)
Number of calls: 18583763 (16.000001 s)
Number of calls: 19755796 (17.000001 s)
Number of calls: 20919874 (18.000002 s)
Number of calls: 22091777 (19.000002 s)
Number of calls: 23254077 (20 s)

$ ./clock-times CLOCK_THREAD_CPUTIME_ID 1.000000001
Clock resolution (id 16 [CLOCK_THREAD_CPUTIME_ID]): 1 ns
Number of calls: 1482190 (1.000000526 s)
Number of calls: 2967183 (2.000000218 s)
Number of calls: 4450908 (3.000000295 s)
Number of calls: 5922409 (4.000000023 s)
Number of calls: 7409630 (5.000000146 s)
Number of calls: 8892111 (6.000000134 s)
Number of calls: 10363763 (7.000000487 s)
Number of calls: 11846771 (8.000000117 s)
Number of calls: 13319756 (9.000000617 s)
Number of calls: 14805122 (10.000000259 s)
Number of calls: 16285822 (11.000000541 s)
Number of calls: 17770013 (12.000000469 s)
Number of calls: 19256055 (13.000000077 s)
Number of calls: 20734939 (14.000000191 s)
Number of calls: 22223024 (15.000000147 s)
Number of calls: 23705385 (16.00000056 s)
Number of calls: 25188424 (17.000000449 s)
Number of calls: 26671774 (18.000000581 s)
Number of calls: 28148777 (19.000000132 s)
Number of calls: 29632634 (20.000000009 s)




More information about the gmp-discuss mailing list