It is surprising that when the program is compiled with the static flag enabled, it runs very fast, doing 10 million calculations in only 0.4 seconds. Nevertheless, when it is compiled without the static flag (that is dynamic binary), the performance becomes very poor, consuming 40 seconds in doing it.
Nice problem! What libraries are being linked in to your executable when linked dynamically?
ldd dynamic-test-cpu-2 Do you see any serious difference in the output files if you run strace -o /tmp/dump-dynamic dynamic-test-cpu-2 vs strace -o /tmp/dump-static static-test-cpu-2 Anything in /var/log/messages? Any possibility that the dynamic one goes to swap for some reason? -Andy
Description: S/MIME Cryptographic Signature