Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disallow struct layout changes #735

Merged
merged 3 commits into from Jan 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 19 additions & 17 deletions bench/bench_FFFrV.rb
@@ -1,24 +1,26 @@
require_relative 'bench_helper'

module LibTest
extend FFI::Library
ffi_lib LIBTEST_PATH
attach_function :bench_f32f32f32_v, [ :float, :float, :float ], :void
def self.rb_bench(a0, a1, a2); nil; end
end
module BenchFFFrV
module LibTest
extend FFI::Library
ffi_lib LIBTEST_PATH
attach_function :bench_f32f32f32_v, [ :float, :float, :float ], :void
def self.rb_bench(a0, a1, a2); nil; end
end


puts "Benchmark [ :float, :float, :float ], :void performance, #{ITER}x calls"
f = 1.0
10.times {
puts Benchmark.measure {
ITER.times { LibTest.bench_f32f32f32_v(f, f, f) }
puts "Benchmark [ :float, :float, :float ], :void performance, #{ITER}x calls"
f = 1.0
10.times {
puts Benchmark.measure {
ITER.times { LibTest.bench_f32f32f32_v(f, f, f) }
}
}
}

puts "Benchmark ruby method(1 arg) performance, #{ITER}x calls"
10.times {
puts Benchmark.measure {
ITER.times { LibTest.rb_bench(f, f, f) }
puts "Benchmark ruby method(1 arg) performance, #{ITER}x calls"
10.times {
puts Benchmark.measure {
ITER.times { LibTest.rb_bench(f, f, f) }
}
}
}
end
60 changes: 31 additions & 29 deletions bench/bench_FrV.rb
@@ -1,36 +1,38 @@
require_relative 'bench_helper'

module LibTest
extend FFI::Library
ffi_lib LIBTEST_PATH
attach_function :bench_f32_v, [ :float ], :void
def self.rb_bench(i0); nil; end
end
module BenchFrV
module LibTest
extend FFI::Library
ffi_lib LIBTEST_PATH
attach_function :bench_f32_v, [ :float ], :void
def self.rb_bench(i0); nil; end
end


puts "Benchmark [ :float ], :void performance, #{ITER}x calls"
f = 1.0
10.times {
puts Benchmark.measure {
i = 0; while i < ITER
LibTest.bench_f32_v(f)
LibTest.bench_f32_v(f)
LibTest.bench_f32_v(f)
LibTest.bench_f32_v(f)
i += 4
end
puts "Benchmark [ :float ], :void performance, #{ITER}x calls"
f = 1.0
10.times {
puts Benchmark.measure {
i = 0; while i < ITER
LibTest.bench_f32_v(f)
LibTest.bench_f32_v(f)
LibTest.bench_f32_v(f)
LibTest.bench_f32_v(f)
i += 4
end
}
}
}

puts "Benchmark ruby method(1 arg) performance, #{ITER}x calls"
10.times {
puts Benchmark.measure {
i = 0; while i < ITER
LibTest.rb_bench(f)
LibTest.rb_bench(f)
LibTest.rb_bench(f)
LibTest.rb_bench(f)
i += 4
end
puts "Benchmark ruby method(1 arg) performance, #{ITER}x calls"
10.times {
puts Benchmark.measure {
i = 0; while i < ITER
LibTest.rb_bench(f)
LibTest.rb_bench(f)
LibTest.rb_bench(f)
LibTest.rb_bench(f)
i += 4
end
}
}
}
end
47 changes: 24 additions & 23 deletions bench/bench_IIIIIIrV.rb
@@ -1,29 +1,30 @@
require_relative 'bench_helper'

module LibTest
extend FFI::Library
ffi_lib LIBTEST_PATH
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
module BenchIIIIIIrV
module LibTest
extend FFI::Library
ffi_lib LIBTEST_PATH
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 {
i = 0; while i < ITER
LibTest.ffi_bench(1, 2, 3, 4, 5, 6)
i += 1
end
puts "Benchmark [ :int, :int, :int, :int, :int, :int ], :void performance, #{ITER}x calls"
10.times {
puts Benchmark.measure {
i = 0; while i < ITER
LibTest.ffi_bench(1, 2, 3, 4, 5, 6)
i += 1
end
}
}
}

puts "Benchmark ruby method(6 arg) performance, #{ITER}x calls"
10.times {
puts Benchmark.measure {
i = 0; while i < ITER
LibTest.rb_bench(0, 1, 2, 3, 4, 5)
i += 1
end
puts "Benchmark ruby method(6 arg) performance, #{ITER}x calls"
10.times {
puts Benchmark.measure {
i = 0; while i < ITER
LibTest.rb_bench(0, 1, 2, 3, 4, 5)
i += 1
end
}
}
}

end
22 changes: 12 additions & 10 deletions bench/bench_IIIrI.rb
@@ -1,15 +1,17 @@
require_relative 'bench_helper'

module LibTest
extend FFI::Library
ffi_lib LIBTEST_PATH
attach_function :bench, :bench_s32s32s32_v, [ :int, :int, :int ], :int
end
module BenchIIIrI
module LibTest
extend FFI::Library
ffi_lib LIBTEST_PATH
attach_function :bench, :bench_s32s32s32_v, [ :int, :int, :int ], :int
end


puts "Benchmark [ :int, :int, :int ], :int performance, #{ITER}x calls"
10.times {
puts Benchmark.measure {
ITER.times { LibTest.bench(0, 1, 2) }
puts "Benchmark [ :int, :int, :int ], :int performance, #{ITER}x calls"
10.times {
puts Benchmark.measure {
ITER.times { LibTest.bench(0, 1, 2) }
}
}
}
end
46 changes: 24 additions & 22 deletions bench/bench_IIIrV.rb
@@ -1,28 +1,30 @@
require_relative 'bench_helper'

module LibTest
extend FFI::Library
ffi_lib LIBTEST_PATH
attach_function :ffi_bench, :bench_s32s32s32_v, [ :int, :int, :int ], :void, :save_errno => false
def self.rb_bench(i0, i1, i2); nil; end
end
module BenchIIIrV
module LibTest
extend FFI::Library
ffi_lib LIBTEST_PATH
attach_function :ffi_bench, :bench_s32s32s32_v, [ :int, :int, :int ], :void, :save_errno => false
def self.rb_bench(i0, i1, i2); nil; end
end

puts "Benchmark [ :int, :int, :int ], :void performance, #{ITER}x calls"
10.times {
puts Benchmark.measure {
i = 0; while i < ITER
LibTest.ffi_bench(0, 1, 2)
i += 1
end
puts "Benchmark [ :int, :int, :int ], :void performance, #{ITER}x calls"
10.times {
puts Benchmark.measure {
i = 0; while i < ITER
LibTest.ffi_bench(0, 1, 2)
i += 1
end
}
}
}

puts "Benchmark ruby method(3 arg) performance, #{ITER}x calls"
10.times {
puts Benchmark.measure {
i = 0; while i < ITER
LibTest.rb_bench(0, 1, 2)
i += 1
end
puts "Benchmark ruby method(3 arg) performance, #{ITER}x calls"
10.times {
puts Benchmark.measure {
i = 0; while i < ITER
LibTest.rb_bench(0, 1, 2)
i += 1
end
}
}
}
end
58 changes: 30 additions & 28 deletions bench/bench_IrV.rb
@@ -1,34 +1,36 @@
require_relative 'bench_helper'

module LibTest
extend FFI::Library
ffi_lib LIBTEST_PATH
attach_function :ffi_bench, :bench_s32_v, [ :int ], :void, :save_errno => false
def self.rb_bench(i0); nil; end
end
module BenchIrV
module LibTest
extend FFI::Library
ffi_lib LIBTEST_PATH
attach_function :ffi_bench, :bench_s32_v, [ :int ], :void, :save_errno => false
def self.rb_bench(i0); nil; end
end

puts "Benchmark [ :int ], :void performance, #{ITER}x calls"
10.times {
puts Benchmark.measure {
i = 0; while i < ITER
LibTest.ffi_bench(0)
LibTest.ffi_bench(0)
LibTest.ffi_bench(0)
LibTest.ffi_bench(0)
i += 4
end
puts "Benchmark [ :int ], :void performance, #{ITER}x calls"
10.times {
puts Benchmark.measure {
i = 0; while i < ITER
LibTest.ffi_bench(0)
LibTest.ffi_bench(0)
LibTest.ffi_bench(0)
LibTest.ffi_bench(0)
i += 4
end
}
}
}

puts "Benchmark ruby method(1 arg) performance, #{ITER}x calls"
10.times {
puts Benchmark.measure {
i = 0; while i < ITER
LibTest.rb_bench(0)
LibTest.rb_bench(0)
LibTest.rb_bench(0)
LibTest.rb_bench(0)
i += 4
end
puts "Benchmark ruby method(1 arg) performance, #{ITER}x calls"
10.times {
puts Benchmark.measure {
i = 0; while i < ITER
LibTest.rb_bench(0)
LibTest.rb_bench(0)
LibTest.rb_bench(0)
LibTest.rb_bench(0)
i += 4
end
}
}
}
end
29 changes: 15 additions & 14 deletions bench/bench_LLLrV.rb
@@ -1,20 +1,21 @@
require_relative 'bench_helper'

module LibTest
extend FFI::Library
ffi_lib LIBTEST_PATH
attach_function :bench_s64s64s64_v, [ :long_long, :long_long, :long_long ], :void, :save_errno => false
end
module BenchLLLrV
module LibTest
extend FFI::Library
ffi_lib LIBTEST_PATH
attach_function :bench_s64s64s64_v, [ :long_long, :long_long, :long_long ], :void, :save_errno => false
end


puts "Benchmark [ :long_long, :long_long, :long_long ], :void performance, #{ITER}x calls"
puts "Benchmark [ :long_long, :long_long, :long_long ], :void performance, #{ITER}x calls"

10.times {
puts Benchmark.measure {
i = 0; while i < ITER
LibTest.bench_s64s64s64_v(0, 1, 2)
i += 1
end
10.times {
puts Benchmark.measure {
i = 0; while i < ITER
LibTest.bench_s64s64s64_v(0, 1, 2)
i += 1
end
}
}
}

end