repo.or.cz
/
jruby.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
history
|
raw
|
HEAD
Fix for JRUBY-2882. Handle error messages related to constructors better
[jruby.git]
/
bench
/
ffi
/
bench_math.rb
blob
a0572b9cdee5f55b374893152f96f5d4d48ff42c
1
require 'benchmark'
2
require 'ffi'
3
4
module FFITest
5
extend FFI::Library
6
ffi_lib 'm'
7
attach_function :cos, [ :double ], :double
8
end
9
if FFITest.cos(0) != 1
10
raise ArgumentError, "FFI.cos returned incorrect value"
11
end
12
puts "Benchmark FFI cos(3m) performance, 10000x"
13
10.times {
14
puts Benchmark.measure {
15
10000.times { FFITest.cos(0) }
16
}
17
}