Skip to content

Commit 082f416

Browse files
committed
Add microbenchmarks for sending to a methods with a block
1 parent b4c36d2 commit 082f416

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

benchmarks.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,14 @@ cfunc_itself:
112112
desc: cfunc_itself just calls the 'itself' method many, many times.
113113
category: micro
114114
single_file: true
115+
send_cfunc_block:
116+
desc: send_cfunc_block just calls a known C function with a block many, many times.
117+
category: micro
118+
single_file: true
119+
send_rubyfunc_block:
120+
desc: send_rubyfunc_block just calls a known Ruby function with a block many, many times.
121+
category: micro
122+
single_file: true
115123
fib:
116124
desc: Fib is a simple exponential-time recursive Fibonacci number generator.
117125
category: micro

benchmarks/send_cfunc_block.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
require_relative '../harness/loader'
2+
3+
ARR = []
4+
5+
run_benchmark(500) do
6+
2_000_000.times do |i|
7+
ARR.each {}
8+
end
9+
end

benchmarks/send_rubyfunc_block.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
require_relative '../harness/loader'
2+
3+
class C
4+
def ruby_func
5+
# Don't even yield
6+
end
7+
end
8+
9+
INSTANCE = C.new
10+
11+
run_benchmark(500) do
12+
2_000_000.times do |i|
13+
INSTANCE.ruby_func {}
14+
end
15+
end

0 commit comments

Comments
 (0)