Kurt StephensNerd Up! | ||||||||
performanceChicagoRuby Ruby Code Tweaks slides, code and video
The slides from my ChicagoRuby 2010/5/4 presentation : http://kurtstephens.com/pub/ruby/ruby_code_tweaks/ All the raw data used to generate the graph should be referenced in the slides. The code used to generate the slides is here: http://github.com/kstephens/ruby_code_tweaks I’m looking to increase the set of code “Problems” to cover other tiny code idioms and platform issues, for example: regular expressions, numerics, etc. If you have ideas, take a look at the code and contact me. Justin Love gave a fantastic presentation on lambda and closure. Thanks to everyone who came — hope it was helpful. Video from the talk: Ruby Code Performance Tweaks by Kurt Stephens from ChicagoRuby on Vimeo. Ruby: Performance of Symbol Construction
Measurements of Symbol Constructor Expressions. n=10_000_000 ruby 1.8.6 (2008-08-08 patchlevel 286) [i686-linux]:
> /cnu/bin/ruby symbol_benchmark.rb
user system total real
Null Test 0.740000 0.000000 0.740000 ( 0.742914)
'foo_bar' 1.670000 0.000000 1.670000 ( 1.661374)
"foo_bar" 1.620000 0.000000 1.620000 ( 1.625221)
:foo_bar 0.890000 0.000000 0.890000 ( 0.886903)
:'foo_bar' 0.880000 0.000000 0.880000 ( 0.878555)
<br class="clear" />
Ruby : Tight Code, Floppy Performance
So you’re coding some ruby, and you do the obligatory caching of a computation:
def foo(x)
666
end
$cache = nil
def cryptic_cached_foo
($cache ||= [ foo("bar") ]).first
end
def nicey_cached_foo
unless $cache
$cache = [ foo("bar") ]
end
$cache.first
end
A discussion came up at work: is |
||||||||
Recent comments
9 weeks 6 days ago
20 weeks 10 hours ago
38 weeks 5 days ago
1 year 2 weeks ago
1 year 36 weeks ago
1 year 48 weeks ago
1 year 51 weeks ago
1 year 51 weeks ago
1 year 51 weeks ago
1 year 51 weeks ago