Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # class implementations up above elided...
- if $0 == __FILE__
- # 0 1 2 3 4 5 6 7 8 9 10 11 12 13
- small_array = [27, 18, 28, 31, 41, 45, 26, 53, 58, 59, 90, 93, 97, 54]
- medium_array = (0..200).map { rand(2**31) + 1 }
- large_array = (0..10_000).map { rand(2**31) + 1 }
- giant_array = (0..100_000).map { rand(2**31) + 1 }
- # Sanity check...
- s = SmoothSort.new
- lm = s.sort(small_array.dup)
- lq = small_array.dup.sort
- raise Exception.new("Sanity Check! Sorted arrays don't match: #{lm.inspect}") unless lm == lq
- # the benchmark_suite code isn't available, so use the standard Ruby benchmark
- require "benchmark" # <== throws an error
- Benchmark.ips do |x|
- x.report("built-in sort small array") do |times|
- i = 0
- while i < times
- small_array.dup.sort
- i += 1
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement