Guest User

Untitled

a guest
Nov 24th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. 1059 j:~ j$ cat hashtest.rb
  2. #!/usr/bin/env ruby
  3. # encoding: utf-8
  4.  
  5. require 'benchmark'
  6.  
  7. Benchmark.bm do |b|
  8. b.report('Sym: ') do
  9. hash = {}
  10. 10_000_000.times { hash[:one] = :foo }
  11. end
  12.  
  13. b.report('Str: ') do
  14. hash = {}
  15. 10_000_000.times { hash['one'] = :foo }
  16. end
  17. end
  18. 1059 j:~ j$ ./hashtest.rb
  19. user system total real
  20. Sym: 6.130000 0.010000 6.140000 ( 6.149491)
  21. Str: 9.770000 0.020000 9.790000 ( 9.810211)
  22. 1100 j:~ j$
Add Comment
Please, Sign In to add comment