Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1059 j:~ j$ cat hashtest.rb
- #!/usr/bin/env ruby
- # encoding: utf-8
- require 'benchmark'
- Benchmark.bm do |b|
- b.report('Sym: ') do
- hash = {}
- 10_000_000.times { hash[:one] = :foo }
- end
- b.report('Str: ') do
- hash = {}
- 10_000_000.times { hash['one'] = :foo }
- end
- end
- 1059 j:~ j$ ./hashtest.rb
- user system total real
- Sym: 6.130000 0.010000 6.140000 ( 6.149491)
- Str: 9.770000 0.020000 9.790000 ( 9.810211)
- 1100 j:~ j$
Add Comment
Please, Sign In to add comment