Skip to content

Instantly share code, notes, and snippets.

@reu
Created December 27, 2010 19:33
Show Gist options
  • Save reu/756454 to your computer and use it in GitHub Desktop.
Save reu/756454 to your computer and use it in GitHub Desktop.
require "benchmark"
n = 100000
klass = Benchmark
Benchmark.bm do |b|
b.report do
n.times { "visit_#{(klass.name || '').gsub('::', '_')}" }
end
b.report do
n.times { "visit_#{(klass.name || '').gsub('::', '_').gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').gsub(/([a-z\d])([A-Z])/,'\1_\2').downcase}" }
end
end
# user system total real
# 0.260000 0.000000 0.260000 ( 0.271001)
# 0.510000 0.000000 0.510000 ( 0.511426)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment