Created
December 27, 2010 19:33
-
-
Save reu/756454 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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