1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/benchmark/array_flatten.yml
Dylan Thacker-Smith a1fda16b23 Optimize Array#flatten and flatten! for already flattened arrays (#2495)
* Optimize Array#flatten and flatten! for already flattened arrays
* Add benchmark for Array#flatten and Array#flatten!

[Bug #16119]
2019-09-28 01:24:24 +09:00

19 lines
751 B
YAML

prelude: |
small_flat_ary = 5.times.to_a
large_flat_ary = 100.times.to_a
small_pairs_ary = [[1, 2]] * 5
large_pairs_ary = [[1, 2]] * 100
mostly_flat_ary = 100.times.to_a.push([101, 102])
benchmark:
small_flat_ary.flatten: small_flat_ary.flatten
small_flat_ary.flatten!: small_flat_ary.flatten!
large_flat_ary.flatten: large_flat_ary.flatten
large_flat_ary.flatten!: large_flat_ary.flatten!
small_pairs_ary.flatten: small_pairs_ary.flatten
small_pairs_ary.flatten!: small_pairs_ary.dup.flatten!
large_pairs_ary.flatten: large_pairs_ary.flatten
large_pairs_ary.flatten!: large_pairs_ary.dup.flatten!
mostly_flat_ary.flatten: mostly_flat_ary.flatten
mostly_flat_ary.flatten!: mostly_flat_ary.dup.flatten!
loop_count: 10000