fork download
  1. require 'benchmark'
  2.  
  3. array = (1..1000000).map { rand }
  4.  
  5. Benchmark.bmbm do |x|
  6. x.report("sort!") {
  7. a=[]
  8. c=0
  9. for i in 0..2000 do
  10. b=[i]
  11. a << b
  12. if a.include?([i]) then
  13. c+=1
  14. end
  15. end
  16. }
  17. x.report("sort") {
  18. x={}
  19. c=0
  20.  
  21. for i in 0..2000 do
  22. y=[i]
  23. x[y] = true
  24. if x[y] == true then
  25. c+=1
  26. end
  27. end
  28. }
  29. end
  30.  
  31.  
  32.  
  33.  
Success #stdin #stdout 1.51s 16412KB
stdin
Standard input is empty
stdout
Rehearsal -----------------------------------------
sort!   0.654022   0.000000   0.654022 (  0.658991)
sort    0.006372   0.000000   0.006372 (  0.006433)
-------------------------------- total: 0.660394sec

            user     system      total        real
sort!   0.660084   0.000000   0.660084 (  0.667164)
sort    0.004561   0.000000   0.004561 (  0.004602)