Created
May 29, 2009 12:12
-
-
Save jodosha/119923 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' | |
OK = "OK".freeze | |
Ok = "OK".freeze | |
Benchmark.bm(30) do |b| | |
b.report('upcase constant') do | |
5_000_000.times { 'OK' == OK } | |
end | |
b.report('camel case constant') do | |
5_000_000.times { 'OK' == Ok } | |
end | |
end | |
__END__ | |
user system total real | |
upcase constant 2.020000 0.010000 2.030000 ( 2.039640) | |
camel case constant 2.040000 0.010000 2.050000 ( 2.057488) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment