mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 05:29:10 +02:00
Add benchmarks for Range#bsearch
This commit is contained in:
parent
6d7730ab98
commit
91042ec0ae
3 changed files with 20 additions and 0 deletions
10
benchmark/range_bsearch_bignum.yml
Normal file
10
benchmark/range_bsearch_bignum.yml
Normal file
|
@ -0,0 +1,10 @@
|
|||
prelude: |
|
||||
first = 2**100
|
||||
last = 2**1000
|
||||
mid = (first + last) / 2
|
||||
r = first..last
|
||||
|
||||
benchmark:
|
||||
first: r.bsearch { |x| x >= first }
|
||||
mid: r.bsearch { |x| x >= mid }
|
||||
last: r.bsearch { |x| x >= last }
|
10
benchmark/range_bsearch_fixnum.yml
Normal file
10
benchmark/range_bsearch_fixnum.yml
Normal file
|
@ -0,0 +1,10 @@
|
|||
prelude: |
|
||||
first = 1
|
||||
last = 10000
|
||||
mid = (first + last) / 2
|
||||
r = first..last
|
||||
|
||||
benchmark:
|
||||
first: r.bsearch { |x| x >= first }
|
||||
mid: r.bsearch { |x| x >= mid }
|
||||
last: r.bsearch { |x| x >= last }
|
Loading…
Add table
Add a link
Reference in a new issue