jodosha (owner)

Revisions

gist: 119923 Download_button fork
public
Public Clone URL: git://gist.github.com/119923.git
Embed All Files: show embed
constants.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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)