Fix for JRUBY-2882. Handle error messages related to constructors better
[jruby.git] / bench / ffi / bench_getpid.rb
blob7e1be824e6339e08b74061bb5cc7b4c28ded4c5a
1 require 'benchmark'
2 require 'ffi'
4 iter = 100000
6 module Posix
7   extend FFI::Library
8   if JRuby::FFI::Platform::IS_WINDOWS
9     attach_function :_getpid, :getpid, [], :pid_t
10   else
11     attach_function :getpid, [], :pid_t
12   end
13 end
16 puts "pid=#{Process.pid} Foo.getpid=#{Posix.getpid}"
17 puts "Benchmark FFI getpid performance, #{iter}x calls"
20 10.times {
21   puts Benchmark.measure {
22     iter.times { Posix.getpid }
23   }
25 puts "Benchmark Process.pid performance, #{iter}x calls"
26 10.times {
27   puts Benchmark.measure {
28     iter.times { Process.pid }
29   }