diff --git a/benchmarks.yml b/benchmarks.yml index b0406a93..906713a3 100644 --- a/benchmarks.yml +++ b/benchmarks.yml @@ -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 known Ruby bmethods many, many times. + category: micro + single_file: true fib: desc: Fib is a simple exponential-time recursive Fibonacci number generator. category: micro diff --git a/benchmarks/send_bmethod.rb b/benchmarks/send_bmethod.rb new file mode 100644 index 00000000..6b3a28b7 --- /dev/null +++ b/benchmarks/send_bmethod.rb @@ -0,0 +1,12 @@ +require_relative '../harness/loader' + +# Call with and without args +define_method(:zero) { :b } +define_method(:one) { |arg| arg } + +run_benchmark(500) do + 2_000_000.times do |i| + zero + one 123 + end +end diff --git a/benchmarks/send_cfunc_block.rb b/benchmarks/send_cfunc_block.rb new file mode 100644 index 00000000..f8551e6d --- /dev/null +++ b/benchmarks/send_cfunc_block.rb @@ -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 diff --git a/benchmarks/send_rubyfunc_block.rb b/benchmarks/send_rubyfunc_block.rb new file mode 100644 index 00000000..1edabf26 --- /dev/null +++ b/benchmarks/send_rubyfunc_block.rb @@ -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