mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
6b3cff12f6
| |compare-ruby|built-ruby| |:-------|-----------:|---------:| |num3 | 96.333k| 160.732k| | | -| 1.67x| |num10 | 96.615k| 159.150k| | | -| 1.65x| |ary2 | 103.836k| 172.787k| | | -| 1.66x| |ary10 | 109.249k| 177.252k| | | -| 1.62x| |ary20 | 106.628k| 177.371k| | | -| 1.66x| |ary50 | 107.135k| 162.282k| | | -| 1.51x| |ary100 | 106.513k| 177.626k| | | -| 1.67x|
16 lines
566 B
YAML
16 lines
566 B
YAML
prelude: |
|
|
num = (1..).lazy.take(100)
|
|
ary2 = [[1,2]].cycle.lazy.take(10)
|
|
ary10 = [[*1..10]].cycle.lazy.take(10)
|
|
ary20 = [[*1..20]].cycle.lazy.take(10)
|
|
ary50 = [[*1..50]].cycle.lazy.take(10)
|
|
ary100 = [[*1..100]].cycle.lazy.take(10)
|
|
|
|
benchmark:
|
|
num3: num.flat_map {|x| x}.take(3).to_a
|
|
num10: num.flat_map {|x| x}.take(3).to_a
|
|
ary2: ary2.flat_map {|x| x}.take(3).to_a
|
|
ary10: ary10.flat_map {|x| x}.take(3).to_a
|
|
ary20: ary20.flat_map {|x| x}.take(3).to_a
|
|
ary50: ary50.flat_map {|x| x}.take(3).to_a
|
|
ary100: ary100.flat_map {|x| x}.take(3).to_a
|