Skip to content

Instantly share code, notes, and snippets.

@chrisseaton
Created March 5, 2015 19:50
Show Gist options
  • Save chrisseaton/67eb3e24f6b02a0cc45c to your computer and use it in GitHub Desktop.
Save chrisseaton/67eb3e24f6b02a0cc45c to your computer and use it in GitHub Desktop.
# Typical mode, runs the block as many times as it can
x.report("addition") { 1 + 2 }
# To reduce overhead, the number of iterations is passed in
# and the block must run the code the specific number of times.
# Used for when the workload is very small and any overhead
# introduces incorrectable errors.
x.report("addition2") do |times|
i = 0
while i < times
1 + 2
i += 1
end
end
# To reduce overhead even more, grafts the code given into
# the loop that performs the iterations internally to reduce
# overhead. Typically not needed, use the |times| form instead.
x.report("addition3", "1 + 2")
# Really long labels should be formatted correctly
x.report("addition-test-long-label") { 1 + 2 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment