Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,18 @@ cfunc_itself:
desc: cfunc_itself just calls the 'itself' method many, many times.
category: micro
single_file: true
send_cfunc_block:
desc: send_cfunc_block just calls a known C function with a block many, many times.
category: micro
single_file: true
send_rubyfunc_block:
desc: send_rubyfunc_block just calls a known Ruby function with a block many, many times.
category: micro
single_file: true
send_bmethod:
desc: send_bmethod just calls a known Ruby bmethod many, many times.
category: micro
single_file: true
fib:
desc: Fib is a simple exponential-time recursive Fibonacci number generator.
category: micro
Expand Down
11 changes: 11 additions & 0 deletions benchmarks/send_bmethod.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require_relative '../harness/loader'

define_method(:zero) { :b }
define_method(:one) { |arg| arg }

run_benchmark(500) do
2_000_000.times do |i|
zero
one 123
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we manually unroll this loop somewhat? I'm kind of concerned this benchmark will spend a significant amount of time dealing with the block entry (for the times method) rather than exercising the define_method method calls.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, that's reasonable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

end
end
12 changes: 12 additions & 0 deletions benchmarks/send_cfunc_block.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
require_relative '../harness/loader'

ARR = []

run_benchmark(500) do
2_000_000.times do |i|
# each is a 0-arg cfunc
ARR.each {}
# index is a variadic cfunc
ARR.index {}
end
end
15 changes: 15 additions & 0 deletions benchmarks/send_rubyfunc_block.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require_relative '../harness/loader'

class C
def ruby_func
# Don't even yield
end
end

INSTANCE = C.new

run_benchmark(500) do
2_000_000.times do |i|
INSTANCE.ruby_func {}
end
end
Loading