Skip to content

Commit

Permalink
Merge pull request #670 from ffi/benchmarks
Browse files Browse the repository at this point in the history
make benchmarks run
  • Loading branch information
tduehr committed Jan 25, 2019
2 parents acbe692 + deea542 commit 7592bfa
Show file tree
Hide file tree
Showing 11 changed files with 3 additions and 259 deletions.
22 changes: 0 additions & 22 deletions bench/bench_FFFrV.rb
Expand Up @@ -22,25 +22,3 @@ def self.rb_bench(a0, a1, a2); nil; end
ITER.times { LibTest.rb_bench(f, f, f) }
}
}

unless RUBY_PLATFORM == "java" && JRUBY_VERSION < "1.3.0"
require 'dl'
require 'dl/import'
module LibTest
if RUBY_VERSION >= "1.9.0"
extend DL::Importer
else
extend DL::Importable
end
dlload LIBTEST_PATH
extern "void bench_f32f32f32_v(float, float, float)"
end
puts "Benchmark DL void bench(float, float, float) performance, #{ITER}x calls"
10.times {
f1 = 1.0; f2 = 2.0; f3 = 3.0
puts Benchmark.measure {
ITER.times { LibTest.bench_f32f32f32_v(f1, f2, f3) }
}
}
end

27 changes: 0 additions & 27 deletions bench/bench_FrV.rb
Expand Up @@ -34,30 +34,3 @@ def self.rb_bench(i0); nil; end
end
}
}

unless RUBY_PLATFORM == "java" && JRUBY_VERSION < "1.3.0"
require 'dl'
require 'dl/import'
module LibTest
if RUBY_VERSION >= "1.9.0"
extend DL::Importer
else
extend DL::Importable
end
dlload LIBTEST_PATH
extern "void bench_f32_v(float)"
end
puts "Benchmark DL void bench(float) performance, #{ITER}x calls"
10.times {
puts Benchmark.measure {
i = 0; while i < ITER
LibTest.bench_f32_v(0)
LibTest.bench_f32_v(0)
LibTest.bench_f32_v(0)
LibTest.bench_f32_v(0)
i += 4
end
}
}
end

28 changes: 2 additions & 26 deletions bench/bench_IIIIIIrV.rb
@@ -1,13 +1,12 @@
require File.expand_path(File.join(File.dirname(__FILE__), "bench_helper"))
METHOD = 'bench_s32s32s32s32s32s32_v'

module LibTest
extend FFI::Library
ffi_lib LIBTEST_PATH
attach_function :ffi_bench, METHOD, [ :int, :int, :int, :int, :int, :int ], :void, :save_errno => false
attach_function :ffi_bench, 'bench_s32s32s32s32s32s32_v', [ :int, :int, :int, :int, :int, :int ], :void, :save_errno => false
def self.rb_bench(i0, i1, i2, i3, i4, i5); nil; end
end


puts "Benchmark [ :int, :int, :int, :int, :int, :int ], :void performance, #{ITER}x calls"
10.times {
puts Benchmark.measure {
Expand All @@ -28,26 +27,3 @@ def self.rb_bench(i0, i1, i2, i3, i4, i5); nil; end
}
}

unless RUBY_PLATFORM == "java" && JRUBY_VERSION < "1.3.0"
require 'dl'
require 'dl/import'
module LibTest
if RUBY_VERSION >= "1.9.0"
extend DL::Importer
else
extend DL::Importable
end
dlload LIBTEST_PATH
extern "void bench_s32s32s32s32s32s32_v(int, int, int, int, int, int)"
end
puts "Benchmark DL void bench(int, int, int) performance, #{ITER}x calls"
10.times {
puts Benchmark.measure {
i = 0; while i < ITER
LibTest.bench_s32s32s32s32s32s32_v(0, 1, 2, 3, 4, 5)
i += 1
end
}
}
end

27 changes: 0 additions & 27 deletions bench/bench_IIIrV.rb
Expand Up @@ -7,21 +7,6 @@ module LibTest
def self.rb_bench(i0, i1, i2); nil; end
end

unless RUBY_PLATFORM == "java" && JRUBY_VERSION < "1.3.0"
require 'dl'
require 'dl/import'
module LibTest
if RUBY_VERSION >= "1.9.0"
extend DL::Importer
else
extend DL::Importable
end
dlload LIBTEST_PATH
extern "void bench_s32s32s32_v(int, int, int)"
end
end


puts "Benchmark [ :int, :int, :int ], :void performance, #{ITER}x calls"
10.times {
puts Benchmark.measure {
Expand All @@ -41,15 +26,3 @@ module LibTest
end
}
}
unless RUBY_PLATFORM == "java" && JRUBY_VERSION < "1.3.0"
puts "Benchmark DL void bench(int, int, int) performance, #{ITER}x calls"
10.times {
puts Benchmark.measure {
i = 0; while i < ITER
LibTest.bench_s32s32s32_v(0, 1, 2)
i += 1
end
}
}
end

27 changes: 0 additions & 27 deletions bench/bench_IrV.rb
Expand Up @@ -6,19 +6,6 @@ module LibTest
attach_function :ffi_bench, :bench_s32_v, [ :int ], :void, :save_errno => false
def self.rb_bench(i0); nil; end
end
unless RUBY_PLATFORM == "java" && JRUBY_VERSION < "1.3.0"
require 'dl'
require 'dl/import'
module LibTest
if RUBY_VERSION >= "1.9.0"
extend DL::Importer
else
extend DL::Importable
end
dlload LIBTEST_PATH
extern "void bench_s32_v(int)"
end
end

puts "Benchmark [ :int ], :void performance, #{ITER}x calls"
10.times {
Expand All @@ -45,17 +32,3 @@ module LibTest
end
}
}

unless RUBY_PLATFORM == "java" && JRUBY_VERSION < "1.3.0"
puts "Benchmark DL void bench(int) performance, #{ITER}x calls"
10.times {
puts Benchmark.measure {
i = 0; while i < ITER
LibTest.bench_s32_v(0)
i += 1
end
}
}
end


30 changes: 0 additions & 30 deletions bench/bench_VrI.rb
Expand Up @@ -7,20 +7,6 @@ module LibTest
def self.rb_bench; 0xdeadbeef; end
end

unless RUBY_PLATFORM == "java" && JRUBY_VERSION < "1.3.0"
require 'dl'
require 'dl/import'
module LibTest
if RUBY_VERSION >= "1.9.0"
extend DL::Importer
else
extend DL::Importable
end
dlload LIBTEST_PATH
extern "int returnInt()"
end
end

puts "Benchmark [ ], :int performance, #{ITER}x calls"
10.times {
puts Benchmark.measure {
Expand Down Expand Up @@ -48,19 +34,3 @@ module LibTest
end
}
}

unless RUBY_PLATFORM == "java" && JRUBY_VERSION < "1.3.0"
puts "Benchmark DL void bench() performance, #{ITER}x calls"
10.times {
puts Benchmark.measure {
i = 0; max = ITER / 4
while i < max
LibTest.returnInt
LibTest.returnInt
LibTest.returnInt
LibTest.returnInt
i += 1
end
}
}
end
28 changes: 0 additions & 28 deletions bench/bench_VrV.rb
Expand Up @@ -8,20 +8,6 @@ module LibTest
def self.rb_bench; nil; end
end

unless RUBY_PLATFORM == "java" && JRUBY_VERSION < "1.3.0"
require 'dl'
require 'dl/import'
module LibTest
if RUBY_VERSION >= "1.9.0"
extend DL::Importer
else
extend DL::Importable
end
dlload LIBTEST_PATH
extern "void returnVoid()"
end
end

puts "Benchmark [ ], :void performance, #{ITER}x calls"
10.times {
puts Benchmark.measure {
Expand All @@ -33,20 +19,6 @@ module LibTest
}
}


unless RUBY_PLATFORM == "java" && JRUBY_VERSION < "1.3.0"
puts "Benchmark DL void bench() performance, #{ITER}x calls"
10.times {
puts Benchmark.measure {
i = 0
while i < ITER
LibTest.returnVoid
i += 1
end
}
}
end

puts "Benchmark [ ], :void no-errno performance, #{ITER}x calls"
10.times {
puts Benchmark.measure {
Expand Down
22 changes: 0 additions & 22 deletions bench/bench_closure_IIIrV.rb
Expand Up @@ -7,19 +7,6 @@ module LibTest
attach_function :ffi_bench, :testClosureIIIrV, [ :closureIIIrV, :int, :int, :int ], :void
def self.rb_bench(a, b, c, &block); yield(a, b, c); end
end
unless RUBY_PLATFORM == "java" && JRUBY_VERSION < "1.3.0"
require 'dl'
require 'dl/import'
module LibTest
if RUBY_VERSION >= "1.9.0"
extend DL::Importer
else
extend DL::Importable
end
dlload LIBTEST_PATH
extern "int returnInt()"
end
end

class Foo
def call(a, b, c); nil; end
Expand Down Expand Up @@ -72,15 +59,6 @@ def call(a, b, c); nil; end
}
}

#unless RUBY_PLATFORM == "java" && JRUBY_VERSION < "1.3.0"
#puts "Benchmark DL void bench() performance, #{ITER}x calls"
#10.times {
# puts Benchmark.measure {
# ITER.times { LibTest.returnInt }
# }
#}
#end

puts "Benchmark ruby method(3 arg), #{ITER}x calls"
10.times {
puts Benchmark.measure {
Expand Down
13 changes: 0 additions & 13 deletions bench/bench_closure_IrV.rb
Expand Up @@ -7,19 +7,6 @@ module LibTest
attach_function :ffi_bench, :testClosureIrV, [ :closureVrV, :int ], :void
def self.rb_bench(i, &block); nil; end
end
unless RUBY_PLATFORM == "java" && JRUBY_VERSION < "1.3.0"
require 'dl'
require 'dl/import'
module LibTest
if RUBY_VERSION >= "1.9.0"
extend DL::Importer
else
extend DL::Importable
end
dlload LIBTEST_PATH
extern "int returnInt()"
end
end

puts "Benchmark [ ], :void closure block performance, #{ITER}x calls"
10.times {
Expand Down
24 changes: 0 additions & 24 deletions bench/bench_closure_VrV.rb
Expand Up @@ -14,20 +14,6 @@ def self.rb_bench(&block)
end
end

unless RUBY_PLATFORM == "java" && JRUBY_VERSION < "1.3.0"
require 'dl'
require 'dl/import'
module LibTest
if RUBY_VERSION >= "1.9.0"
extend DL::Importer
else
extend DL::Importable
end
dlload LIBTEST_PATH
extern "int returnInt()"
end
end

puts "Benchmark [ ], :void closure block performance, #{ITER}x calls"
10.times {
puts Benchmark.measure {
Expand Down Expand Up @@ -59,16 +45,6 @@ module LibTest
}
}


#unless RUBY_PLATFORM == "java" && JRUBY_VERSION < "1.3.0"
#puts "Benchmark DL void bench() performance, #{ITER}x calls"
#10.times {
# puts Benchmark.measure {
# ITER.times { LibTest.returnInt }
# }
#}
#end

puts "Benchmark ruby method(no arg) performance, #{ITER}x calls"
10.times {
puts Benchmark.measure {
Expand Down
14 changes: 1 addition & 13 deletions bench/bench_enum.rb
Expand Up @@ -29,25 +29,13 @@ def self.rb_bench(i0); nil; end
ITER.times { LibTest.ffi_bench_i(1) }
}
}

puts "Benchmark [ :int ], :void with enum arg performance, #{ITER}x calls"
10.times {
puts Benchmark.measure {
ITER.times { LibTest.ffi_bench_i(:a) }
}
}
unless RUBY_PLATFORM == "java" && JRUBY_VERSION < "1.3.0"
require 'dl'
require 'dl/import'
module LibTest
if RUBY_VERSION >= "1.9.0"
extend DL::Importer
else
extend DL::Importable
end
dlload LIBTEST_PATH
extern "void bench_s32_v(int)"
end
end

puts "Benchmark ruby method(1 arg) performance, #{ITER}x calls"
10.times {
Expand Down

0 comments on commit 7592bfa

Please sign in to comment.