Skip to content

Instantly share code, notes, and snippets.

@sergey-chechaev
Created September 20, 2017 09:03
Show Gist options
  • Save sergey-chechaev/336fce2a16f5f196c57b21e675b14284 to your computer and use it in GitHub Desktop.
Save sergey-chechaev/336fce2a16f5f196c57b21e675b14284 to your computer and use it in GitHub Desktop.
require 'benchmark'
data = (0..50_000_000)
Benchmark.bm do |x|
x.report(:find) { data.find {|number| number > 40_000_000 } }
x.report(:bsearch) { data.bsearch {|number| number > 40_000_000 } }
end
user system total real
find 3.020000 0.010000 3.030000 (3.028417)
bsearch 0.000000 0.000000 0.000000 (0.000006)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment