summaryrefslogtreecommitdiff
path: root/bench
diff options
context:
space:
mode:
authorWayne Meissner <wmeissner@gmail.com>2011-08-12 17:44:35 +1000
committerWayne Meissner <wmeissner@gmail.com>2011-08-18 19:19:17 +1000
commit251392913e4fcca1a299df9b14978d1c2bd15ef5 (patch)
tree1d3ae1f589e225fb696e679e7af30bf7d5131bd4 /bench
parent6711fb945552b59654ff26296cdec87ff4f3af8e (diff)
downloadffi-251392913e4fcca1a299df9b14978d1c2bd15ef5.tar.gz
Add non-ruby-thread callback benchmarks
Diffstat (limited to 'bench')
-rw-r--r--bench/bench_closure_VrV.rb17
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 {