Skip to content

Instantly share code, notes, and snippets.

@davepacheco
Last active May 3, 2016 04:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davepacheco/a12a0d45d55f0d7a28c312c2cd3cf234 to your computer and use it in GitHub Desktop.
Save davepacheco/a12a0d45d55f0d7a28c312c2cd3cf234 to your computer and use it in GitHub Desktop.
# I've got a shell for testing:
testshell $ echo $$
2133
# From a second shell, I'll instrument every instruction, function entry,
# and function return in the first shell, which is about 142,000 probes:
tracer $ dtrace -ln 'pid2133:a.out::' | wc -l
142008
tracer $ dtrace -n 'pid2133:a.out::{ @ = count(); }'
dtrace: description 'pid2133:a.out::' matched 142007 probes
# Now I'll run this loop in the first shell:
testshell $ time for ((i = 0; i < 10000; i++)) { :; }
real 3m38.393s
user 3m28.516s
sys 0m0.300s
# Here's the full output from the second shell:
tracer $ dtrace -n 'pid2133:a.out::{ @ = count(); }'
dtrace: description 'pid2133:a.out::' matched 142007 probes
^C
161566411
# That's 161566411 probes executed in 218.393s, for about
# 1352 nanoseconds per probe.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment