Skip to content

Instantly share code, notes, and snippets.

@headius
Created December 24, 2012 05:48
Show Gist options
  • Save headius/4367878 to your computer and use it in GitHub Desktop.
Save headius/4367878 to your computer and use it in GitHub Desktop.
system ~/projects/jruby $ jruby -Xcompile.invokedynamic=true ../jruby/static_versus_include_bench.rb
Session Static versus included method invocation with jruby 1.7.2.dev (1.9.3p327) 2012-12-22 51cc3ad on Java HotSpot(TM) 64-Bit Server VM 1.7.0_09-b05 +indy [darwin-x86_64]
Taking 10 measurements of at least 1.0s
control loop 6.819 ns/i ± 0.135 ( 2.0%) <=> 146646998 ips
static invocation 7.062 ns/i ± 0.223 ( 3.2%) <=> 141594132 ips
included invocation 7.017 ns/i ± 0.074 ( 1.1%) <=> 142514900 ips
system ~/projects/jruby $ ruby-1.9.3 ../jruby/static_versus_include_bench.rb
Session Static versus included method invocation with ruby 1.9.3p253 (2012-07-04 revision 36307) [x86_64-darwin11.4.0]
Taking 10 measurements of at least 1.0s
control loop 35.92 ns/i ± 2.969 ( 8.3%) <=> 27834072 ips
static invocation 366.5 ns/i ± 6.599 ( 1.8%) <=> 2728493 ips
included invocation 367.5 ns/i ± 1.457 ( 0.4%) <=> 2720714 ips
system ~/projects/jruby $ ../rubinius/bin/rbx -X19 ../jruby/static_versus_include_bench.rb
Session Static versus included method invocation with rubinius 2.0.0rc1 (1.9.3 d2326d8e 2012-11-02 JI) [x86_64-apple-darwin11.4.2]
Taking 10 measurements of at least 1.0s
control loop 9.705 ns/i ± 0.085 ( 0.9%) <=> 103044436 ips
static invocation 16.75 ns/i ± 0.097 ( 0.6%) <=> 59675619 ips
included invocation 11.95 ns/i ± 0.124 ( 1.0%) <=> 83654942 ips
system ~/projects/jruby $ cat static_versus_include_bench.rb
require 'perfer'
module Foo
def foo
self
end
module_function :foo
public :foo
end
class Bar
include Foo
end
Perfer.session 'Static versus included method invocation' do |s|
s.iterate 'control loop' do |n|
while n > 0
n -= 1
end
end
s.iterate 'static invocation' do |n|
while n > 0
Foo.foo
n -= 1
end
end
s.iterate 'included invocation' do |n|
bar = Bar.new
while n > 0
bar.foo
n -= 1
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment