Skip to content

Commit

Permalink
Use FFI:: Instead of JRuby::FFI:: where possible
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.codehaus.org/jruby/trunk/jruby@8199 961051c9-f516-0410-bf72-c9f7e237a7b7
  • Loading branch information
vp-of-awesome committed Nov 29, 2008
1 parent e2efb52 commit ea65b9a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion bench/ffi/bench_chmod.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def self.chmod(mode, path)
if self._chmod(path, mode) != 0
end
end
if JRuby::FFI::Platform::IS_WINDOWS
if FFI::Platform.windows?
attach_function :_chmod, :_chmod, [ :string, :int ], :int
else
attach_function :_chmod, :chmod, [ :string, :int ], :int
Expand Down
8 changes: 4 additions & 4 deletions bench/ffi/bench_memchr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
require 'ffi'
iter = 10000
str = "test" * 1000
module JLibC
module LibC
extend FFI::Library
attach_function :memchr, [ :string, :char, :int ], :pointer
end

if JLibC.memchr("test", 't', 4).nil?
raise ArgumentError, "JRuby::FFI.memchr returned incorrect value"
if LibC.memchr("test", 't', 4).nil?
raise ArgumentError, "FFI memchr returned incorrect value"
end

puts "Benchmark FFI memchr(3) performance, #{iter}x"
10.times {
puts Benchmark.measure {
iter.times { JLibC.memchr(str, 't', 4) }
iter.times { LibC.memchr(str, 't', 4) }
}
}
2 changes: 1 addition & 1 deletion bench/ffi/bench_stat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module Posix
extend FFI::Library
attach_function :stat, [ :string, :pointer ], :int
end
class Stat < JRuby::FFI::Struct
class Stat < FFI::Struct
layout \
:st_dev => :int, # device inode resides on (dev_t)
:st_ino => :int, # inode's number (ino_t)
Expand Down
6 changes: 3 additions & 3 deletions bench/ffi/bench_strlen.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
iter = 100000
str = "test"

module JLibC
module LibC
extend FFI::Library
attach_function :strlen, [ :string ], :int
end

if JLibC.strlen("test") != 4
if LibC.strlen("test") != 4
raise ArgumentError, "jruby FFI.strlen returned incorrect value"
end

puts "Benchmark jruby FFI api strlen(3) performance, #{iter}x"
10.times {
puts Benchmark.measure {
iter.times { JLibC.strlen(str) }
iter.times { LibC.strlen(str) }
}
}

0 comments on commit ea65b9a

Please sign in to comment.