Last active
December 11, 2015 10:58
-
-
Save gkop/4590606 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark' | |
array = (0..10000000).to_a | |
benchmark = Benchmark.bm(10) do |x| | |
x.report("Ruby 2.0: ") do | |
100000.times { array.bsearch { |e| 7777777 <=> e } } | |
end | |
require 'bsearch' | |
x.report("bsearch gem:") do | |
100000.times { array.bsearch { |e| 7777777 <=> e } } | |
end | |
end | |
# user system total real | |
# Ruby 2.0: 0.180000 0.000000 0.180000 ( 0.185011) | |
# bsearch gem: 0.750000 0.000000 0.750000 ( 0.761949) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment