Skip to content

Instantly share code, notes, and snippets.

@jordansissel
Created March 16, 2016 22:08
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 jordansissel/1427b9523cada667a33e to your computer and use it in GitHub Desktop.
Save jordansissel/1427b9523cada667a33e to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
#
require "cabin"
require "benchmark"
c = Cabin::Channel.get
iterations = 100_000
msg = "ok"
Benchmark.bmbm(30) do |x|
[:info, :debug].each do |level|
c.level = level
x.report("#{level}: nothing") do
iterations.times { }
end
x.report("#{level}: debug? (#{c.debug?})") do
iterations.times { c.debug? }
end
x.report("#{level}: debug? && debug() (#{c.debug?})") do
iterations.times { c.debug? && c.debug(msg) }
end
x.report("#{level}: debug() (#{c.debug?})") do
iterations.times { c.debug(msg) }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment