7 extend JRuby::FFI::Library
8 attach_function :strlen, [ :string ], :int
12 attach_function :strlen, [ :string ], :int
15 if RbxLibC.strlen("test") != 4
16 raise ArgumentError, "rubinius FFI.strlen returned incorrect value"
18 if JLibC.strlen("test") != 4
19 raise ArgumentError, "jruby FFI.strlen returned incorrect value"
21 puts "Benchmark rubinius FFI api strlen(3) performance, #{iter}x"
23 puts Benchmark.measure {
24 iter.times { RbxLibC.strlen(str) }
28 puts "Benchmark jruby FFI api strlen(3) performance, #{iter}x"
30 puts Benchmark.measure {
31 iter.times { JLibC.strlen(str) }