-
-
Notifications
You must be signed in to change notification settings - Fork 942
Closed
Description
Environment
Darwin Joaos-MBP.lan 15.3.0 Darwin Kernel Version 15.3.0: Thu Dec 10 18:40:58 PST 2015; root:xnu-3248.30.4~1/RELEASE_X86_64 x86_64
java version "1.8.0_20"
Java(TM) SE Runtime Environment (build 1.8.0_20-b26)
Java HotSpot(TM) 64-Bit Server VM (build 25.20-b23, mixed mode)
Testing the following code:
require 'benchmark/ips'
class Slow
m = :meh?
define_method(m) do
return m
end
end
class Fast
m = :meh?
define_method(m) do
m
end
end
f = Fast.new
s = Slow.new
Benchmark.ips do |x|
x.config(:time => 6, :warmup => 3)
x.report("slow") { s.meh? }
x.report("fast") { f.meh? }
x.compare!
endExpected Behavior
I expect the slowness of the Slow class to be consistent across ruby implementations
Actual Behavior
% rvm ruby-2.2.1,jruby-1.7.23,jruby-9.0.5.0 do ruby def_method.rb
# ruby 2.2.1
Warming up --------------------------------------
slow 116.300k i/100ms
fast 122.202k i/100ms
Calculating -------------------------------------
slow 4.492M (± 7.4%) i/s - 26.865M
fast 5.591M (± 8.8%) i/s - 33.239M
Comparison:
fast: 5590653.4 i/s
slow: 4492099.6 i/s - 1.24x slower
# jruby 1.7.23
Warming up --------------------------------------
slow 154.333k i/100ms
fast 189.819k i/100ms
Calculating -------------------------------------
slow 2.793M (± 4.9%) i/s - 16.822M
fast 6.102M (± 6.2%) i/s - 36.445M
Comparison:
fast: 6101768.0 i/s
slow: 2792631.3 i/s - 2.18x slower
# jruby 9.0.5.0
Warming up --------------------------------------
slow 9.248k i/100ms
fast 144.102k i/100ms
Calculating -------------------------------------
slow 114.075k (± 6.7%) i/s - 684.352k
fast 7.562M (± 8.3%) i/s - 44.816M
Comparison:
fast: 7561944.8 i/s
slow: 114074.7 i/s - 66.29x slower
Reactions are currently unavailable