Skip to content

Instantly share code, notes, and snippets.

@jorendorff
Created March 29, 2018 16:32
Show Gist options
  • Save jorendorff/a2a9750d0ca14f2f740d656e68966f88 to your computer and use it in GitHub Desktop.
Save jorendorff/a2a9750d0ca14f2f740d656e68966f88 to your computer and use it in GitHub Desktop.
~/play/sine/timings$ make
c++ -O2 -std=c++11 -c -o clock_gettime.o clock_gettime.cc
c++ -O2 -std=c++11 -c -o lib.o lib.cc
c++ -O2 -std=c++11 clock_gettime.o lib.o -o clock_gettime
c++ -O2 -std=c++11 -c -o fwrite.o fwrite.cc
c++ -O2 -std=c++11 fwrite.o lib.o -o fwrite
c++ -O2 -std=c++11 -c -o mutex.o mutex.cc
c++ -O2 -std=c++11 mutex.o lib.o -o mutex
c++ -O2 -std=c++11 -c -o time-delta.o time-delta.cc
c++ -O2 -std=c++11 time-delta.o lib.o -o time-delta
c++ -O2 -std=c++11 -c -o write.o write.cc
c++ -O2 -std=c++11 write.o lib.o -o write
set -x && ./clock_gettime && ./fwrite && ./mutex && ./time-delta && ./write
+ ./clock_gettime
21.3339s for 300Mcall, 14.1 megacalls per second, 71.1 nanoseconds per call
+ ./fwrite
open output file: 70µs
write words to file: 0.277515s, 115.3MiB/s, 66.2ns/W
+ ./mutex
24.3752s for 1Gtransaction, 41 megatransactions per second, 24.4 nanoseconds per transaction
+ ./time-delta
empty loop: 1Gop, 1.62415s, 615.7Mop/s, 1.6ns/op
just generate random time values: 1Gop, 4.90355s, 203.9Mop/s, 4.9ns/op
Subsequent measurements subtract out the above time.
subtract without carry: 1Gop, 0.122671s, 8.2Gop/s, 0.1ns/op
subtract without carry, five times (sanity check): 5Gop, 10.6675s, 468.7Mop/s, 2.1ns/op
subtract without carry, ten times (sanity check): 10Gop, 20.2452s, 493.9Mop/s, 2ns/op
subtract without carry, fifteen times (sanity check): 15Gop, 29.7873s, 503.6Mop/s, 2ns/op
carry via branch: 1Gop, 3.94698s, 253.4Mop/s, 3.9ns/op
carry via modulo: 1Gop, 0.908124s, 1.1Gop/s, 0.9ns/op
+ ./write
allocate 1GiB buffer: 13µs
initialize buffer, first pass: 0.549796s, 1.8GiB/s, 0.5ns/B
initialize buffer, second pass: 0.13368s, 7.5GiB/s, 0.1ns/B
initialize buffer, third pass: 0.115362s, 8.7GiB/s, 0.1ns/B
initialize as words, first pass: 0.116879s, 8.6GiB/s, 0.9ns/W
initialize as words, second pass: 0.115227s, 8.7GiB/s, 0.9ns/W
initialize as words, third pass: 0.115007s, 8.7GiB/s, 0.9ns/W
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment