5 require File.join(JRuby::FFI::Platform::CONF_DIR, "etc")
6 Passwd = Platform::Etc::Passwd
11 extend JRuby::FFI::Library
12 attach_function :getpwnam, [ :string ], :pointer
16 attach_function :getpwnam, [ :string ], :pointer
21 ffiname = Passwd.new(JPosix.getpwnam(login))[:pw_name]
22 etcname = Etc.getpwnam(login).name
23 puts "pw_name does not match Etc.getpwnam.name" if ffiname != etcname
25 pwd = Etc.getpwnam(login)
26 puts "members=#{pwd.members.inspect}"
27 puts "values=#{pwd.values.inspect}"
29 pwd = Passwd.new(JPosix.getpwnam(login))
30 puts "members=#{pwd.members.inspect}"
31 puts "values=#{pwd.values.inspect}"
34 puts "Benchmark FFI getpwnam (rubinius api) performance, #{iter}x"
37 puts Benchmark.measure {
39 pwd = Passwd.new RbxPosix.getpwnam(login)
46 puts "Benchmark FFI getpwnam (jruby api) performance, #{iter}x"
49 puts Benchmark.measure {
51 pwd = Passwd.new JPosix.getpwnam(login)
58 puts "Benchmark Etc.getpwnam performance, #{iter}x"
60 puts Benchmark.measure {
62 pwd = Etc.getpwnam(login);