Created
January 8, 2015 15:05
-
-
Save headius/a302a0dd772d55f8213c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~/projects/jruby $ jruby -X-C bench_yield.rb | |
Calculating ------------------------------------- | |
yield 48.297k i/100ms | |
block.call 56.451k i/100ms | |
method dispatch 79.492k i/100ms | |
------------------------------------------------- | |
yield 1.471M (±10.8%) i/s - 7.245M | |
block.call 1.537M (± 7.0%) i/s - 7.621M | |
method dispatch 2.587M (± 7.7%) i/s - 12.878M | |
[] | |
~/projects/jruby $ jruby bench_yield.rb | |
Calculating ------------------------------------- | |
yield 49.195k i/100ms | |
block.call 59.350k i/100ms | |
method dispatch 93.706k i/100ms | |
------------------------------------------------- | |
yield 1.429M (±30.9%) i/s - 5.707M | |
block.call 1.411M (±29.8%) i/s - 5.757M | |
method dispatch 7.938M (±15.7%) i/s - 38.045M | |
[] | |
~/projects/jruby $ jruby -Xcompile.invokedynamic=true bench_yield.rb | |
Calculating ------------------------------------- | |
yield 65.343k i/100ms | |
block.call 70.080k i/100ms | |
method dispatch 157.996k i/100ms | |
------------------------------------------------- | |
yield 1.843M (±35.2%) i/s - 6.861M | |
block.call 1.853M (±33.8%) i/s - 7.008M | |
method dispatch 19.077M (±18.4%) i/s - 89.426M | |
[] | |
~/projects/jruby $ rvm jruby-1.7.18 do ruby -X-C bench_yield.rb | |
Calculating ------------------------------------- | |
yield 88.631k i/100ms | |
block.call 92.329k i/100ms | |
method dispatch 119.450k i/100ms | |
------------------------------------------------- | |
yield 3.489M (±10.5%) i/s - 17.283M | |
block.call 2.505M (± 9.1%) i/s - 12.464M | |
method dispatch 4.528M (± 9.7%) i/s - 22.457M | |
[] | |
~/projects/jruby $ rvm jruby-1.7.18 do ruby bench_yield.rb | |
Calculating ------------------------------------- | |
yield 173.511k i/100ms | |
block.call 166.776k i/100ms | |
method dispatch 218.508k i/100ms | |
------------------------------------------------- | |
yield 7.064M (±10.5%) i/s - 34.876M | |
block.call 4.889M (± 8.5%) i/s - 24.349M | |
method dispatch 11.382M (±12.5%) i/s - 55.938M | |
[] | |
~/projects/jruby $ rvm jruby-1.7.18 do ruby -Xcompile.invokedynamic=true bench_yield.rb | |
Calculating ------------------------------------- | |
yield 155.704k i/100ms | |
block.call 156.176k i/100ms | |
method dispatch 223.343k i/100ms | |
------------------------------------------------- | |
yield 9.326M (±13.2%) i/s - 45.466M | |
block.call 5.977M (± 9.3%) i/s - 29.673M | |
method dispatch 16.960M (±15.1%) i/s - 82.637M | |
[] | |
~/projects/jruby $ rvm ruby-2.2 do ruby bench_yield.rb | |
Calculating ------------------------------------- | |
yield 98.045k i/100ms | |
block.call 55.876k i/100ms | |
method dispatch 99.495k i/100ms | |
------------------------------------------------- | |
yield 4.947M (±11.6%) i/s - 24.413M | |
block.call 1.072M (± 7.4%) i/s - 5.364M | |
method dispatch 6.283M (±12.9%) i/s - 30.943M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark/ips' | |
class Yield | |
def call | |
yield | |
end | |
end | |
class BlockCall | |
def call(&block) | |
block.call | |
end | |
end | |
class MethodDispatch | |
def call | |
end | |
end | |
a = Yield.new | |
b = BlockCall.new | |
c = MethodDispatch.new | |
Benchmark.ips do |ips| | |
ips.report("yield") do | |
a.() {} | |
end | |
ips.report("block.call") do | |
b.() {} | |
end | |
ips.report("method dispatch") do | |
c.() | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment