diff options
Diffstat (limited to 'bench')
-rw-r--r-- | bench/bench_closure_VrV.rb | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/bench/bench_closure_VrV.rb b/bench/bench_closure_VrV.rb index f7501fc..20a92a4 100644 --- a/bench/bench_closure_VrV.rb +++ b/bench/bench_closure_VrV.rb @@ -4,9 +4,15 @@ module LibTest extend FFI::Library ffi_lib LIBTEST_PATH callback :closureVrV, [ ], :void + attach_function :ffi_bench, :testClosureVrV, [ :closureVrV ], :void - def self.rb_bench(&block); yield; end + attach_function :threaded_bench, :testThreadedClosureVrV, [ :closureVrV, :int ], :void + + def self.rb_bench(&block) + yield + end end + unless RUBY_PLATFORM == "java" && JRUBY_VERSION < "1.3.0" require 'dl' require 'dl/import' @@ -44,6 +50,15 @@ puts "Benchmark [ ], :void pre-allocated closure performance, #{ITER}x calls" } } +puts "Benchmark [ ], :void non-ruby thread closure performance, #{ITER}x calls" +10.times { + fn = FFI::Function.new(:void, []) {} + puts Benchmark.measure { + LibTest.threaded_bench(fn, ITER) + } +} + + #unless RUBY_PLATFORM == "java" && JRUBY_VERSION < "1.3.0" #puts "Benchmark DL void bench() performance, #{ITER}x calls" #10.times { |