Skip to content

Commit 68015c1

Browse files
committed
Add getuid benchmark
git-svn-id: http://svn.codehaus.org/jruby/trunk/jruby@7435 961051c9-f516-0410-bf72-c9f7e237a7b7
1 parent 2db8c40 commit 68015c1

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

test/bench/ffi/bench_getuid.rb

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
require 'benchmark'
2+
require 'ffi'
3+
4+
iter = 100000
5+
6+
module Posix
7+
extend FFI::Library
8+
attach_function :getuid, [], :uid_t
9+
end
10+
11+
12+
puts "uid=#{Process.pid} Posix.getuid=#{Posix.getuid}"
13+
puts "Benchmark FFI getuid performance, #{iter}x calls"
14+
15+
10.times {
16+
puts Benchmark.measure {
17+
iter.times { Posix.getuid }
18+
}
19+
}
20+
puts "Benchmark Process.uid performance, #{iter}x calls"
21+
10.times {
22+
puts Benchmark.measure {
23+
iter.times { Process.uid }
24+
}
25+
}

0 commit comments

Comments
 (0)