Skip to content

Instantly share code, notes, and snippets.

@jorendorff
Created March 29, 2018 13:17
Show Gist options
  • Select an option

  • Save jorendorff/0ed98ad7319bb461d3e12ad3580e6a32 to your computer and use it in GitHub Desktop.

Select an option

Save jorendorff/0ed98ad7319bb461d3e12ad3580e6a32 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
18.3008s for 300Mcall, 16.4 megacalls per second, 61 nanoseconds per call
+ ./fwrite
open output file: 59µs
write words to file: 0.259152s, 123.5MiB/s, 61.8ns/W
+ ./mutex
21.3345s for 1Gtransaction, 46.9 megatransactions per second, 21.3 nanoseconds per transaction
+ ./time-delta
empty loop: 1Gop, 1.4419s, 693.5Mop/s, 1.4ns/op
just generate random time values: 1Gop, 4.27548s, 233.9Mop/s, 4.3ns/op
Subsequent measurements subtract out the above time.
subtract without carry: 1Gop, 42.2ms, 23.7Gop/s, 0ns/op
subtract without carry, ten times (sanity check): 10Gop, 17.5419s, 570.1Mop/s, 1.8ns/op
carry via branch: 1Gop, 3.33809s, 299.6Mop/s, 3.3ns/op
carry via modulo: 1Gop, 0.808303s, 1.2Gop/s, 0.8ns/op
+ ./write
allocate 1GiB buffer: 10µs
initialize buffer, first pass: 0.455385s, 2.2GiB/s, 0.4ns/B
initialize buffer, second pass: 0.105901s, 9.4GiB/s, 0.1ns/B
initialize buffer, third pass: 0.110313s, 9.1GiB/s, 0.1ns/B
initialize as words, first pass: 0.109382s, 9.1GiB/s, 0.8ns/W
initialize as words, second pass: 0.110747s, 9GiB/s, 0.8ns/W
initialize as words, third pass: 0.111521s, 9GiB/s, 0.8ns/W
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment