mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
a1fda16b23
* Optimize Array#flatten and flatten! for already flattened arrays * Add benchmark for Array#flatten and Array#flatten! [Bug #16119]
19 lines
751 B
YAML
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
|