summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWayne Meissner <wmeissner@gmail.com>2012-04-08 05:47:00 +1000
committerWayne Meissner <wmeissner@gmail.com>2012-04-08 05:48:06 +1000
commit13949919c2985df939fa63327003728c5b68afdf (patch)
tree1a4761656e505f214129549434afe87f5206bf46
parentdea52a19adf4a490699c54a609fefe8f6d015423 (diff)
downloadffi-13949919c2985df939fa63327003728c5b68afdf.tar.gz
Use while loops instead of blocks in some benchmarks
-rw-r--r--bench/bench_VrI.rb32
1 files changed, 26 insertions, 6 deletions
diff --git a/bench/bench_VrI.rb b/bench/bench_VrI.rb
index 17a17ee..1f3ec25 100644
--- a/bench/bench_VrI.rb
+++ b/bench/bench_VrI.rb
@@ -3,7 +3,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), "bench_helper"))
module LibTest
extend FFI::Library
ffi_lib LIBTEST_PATH
- attach_function :ffi_bench, :returnInt, [ ], :int
+ attach_function :ffi_bench, :returnInt, [ ], :int, :save_errno => false
def self.rb_bench; nil; end
end
unless RUBY_PLATFORM == "java" && JRUBY_VERSION < "1.3.0"
@@ -23,7 +23,11 @@ end
puts "Benchmark [ ], :int performance, #{ITER}x calls"
10.times {
puts Benchmark.measure {
- ITER.times { LibTest.ffi_bench }
+ i = 0
+ while i < ITER
+ LibTest.ffi_bench
+ i += 1
+ end
}
}
@@ -32,7 +36,11 @@ unless RUBY_PLATFORM == "java" && JRUBY_VERSION < "1.3.0"
puts "Benchmark DL void bench() performance, #{ITER}x calls"
10.times {
puts Benchmark.measure {
- ITER.times { LibTest.returnInt }
+ i = 0
+ while i < ITER
+ LibTest.returnInt
+ i += 1
+ end
}
}
end
@@ -41,7 +49,11 @@ puts "Benchmark Invoker.call [ ], :int performance, #{ITER}x calls"
invoker = FFI.create_invoker(LIBTEST_PATH, 'returnInt', [ ], :int)
10.times {
puts Benchmark.measure {
- ITER.times { invoker.call }
+ i = 0
+ while i < ITER
+ invoker.call
+ i += 1
+ end
}
}
@@ -51,14 +63,22 @@ module NoErrno ;end
f.attach(NoErrno, "ffi_bench")
10.times {
puts Benchmark.measure {
- ITER.times { NoErrno.ffi_bench }
+ i = 0
+ while i < ITER
+ NoErrno.ffi_bench
+ i += 1
+ end
}
}
puts "Benchmark ruby method(no arg) performance, #{ITER}x calls"
10.times {
puts Benchmark.measure {
- ITER.times { LibTest.rb_bench }
+ i = 0
+ while i < ITER
+ LibTest.rb_bench
+ i += 1
+ end
}
}