File tree Expand file tree Collapse file tree 3 files changed +50
-3
lines changed
Expand file tree Collapse file tree 3 files changed +50
-3
lines changed Original file line number Diff line number Diff line change 55define_method ( :one ) { |arg | arg }
66
77run_benchmark ( 500 ) do
8- 2_000_000 . times do |i |
8+ 500_000 . times do |i |
9+ # Manually unrolling to avoid loop overhead
10+ zero
11+ one 123
12+ zero
13+ one 123
14+ zero
15+ one 123
16+ zero
17+ one 123
18+ zero
19+ one 123
20+ zero
21+ one 123
22+ zero
23+ one 123
24+ zero
25+ one 123
926 zero
1027 one 123
1128 end
Original file line number Diff line number Diff line change 33ARR = [ ]
44
55run_benchmark ( 500 ) do
6- 2_000_000 . times do |i |
6+ 500_000 . times do |i |
77 # each is a 0-arg cfunc
88 ARR . each { }
99 # index is a variadic cfunc
10+ # Manually unrolling to avoid loop overhead
11+ ARR . index { }
12+ ARR . each { }
13+ ARR . index { }
14+ ARR . each { }
15+ ARR . index { }
16+ ARR . each { }
17+ ARR . index { }
18+ ARR . each { }
19+ ARR . index { }
20+ ARR . each { }
21+ ARR . index { }
22+ ARR . each { }
23+ ARR . index { }
24+ ARR . each { }
25+ ARR . index { }
26+ ARR . each { }
27+ ARR . index { }
28+ ARR . each { }
29+ ARR . index { }
30+ ARR . each { }
1031 ARR . index { }
1132 end
1233end
Original file line number Diff line number Diff line change @@ -9,7 +9,16 @@ def ruby_func
99INSTANCE = C . new
1010
1111run_benchmark ( 500 ) do
12- 2_000_000 . times do |i |
12+ 500_000 . times do |i |
13+ # Manually unrolling to avoid loop overhead
14+ INSTANCE . ruby_func { }
15+ INSTANCE . ruby_func { }
16+ INSTANCE . ruby_func { }
17+ INSTANCE . ruby_func { }
18+ INSTANCE . ruby_func { }
19+ INSTANCE . ruby_func { }
20+ INSTANCE . ruby_func { }
21+ INSTANCE . ruby_func { }
1322 INSTANCE . ruby_func { }
1423 end
1524end
You can’t perform that action at this time.
0 commit comments