Eric Hodel
Posts: 660
Nickname: drbrain
Registered: Mar, 2006
Eric Hodel is a long-time Rubyist and co-founder of Seattle.rb.
I wrote an inliner
Posted: Jun 27, 2007 2:08 AM
This post originated from an RSS feed registered with Ruby Buzz
by Eric Hodel.
Original Post: I wrote an inliner
Feed Title: Segment7
Feed URL: http://blog.segment7.net/articles.rss
Feed Description: Posts about and around Ruby, MetaRuby, ruby2c, ZenTest and work at The Robot Co-op.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Eric Hodel
Latest Posts From Segment7
Advertisement
$ ruby test.rb
caller result: 12
caller:
def caller
v1 = (2 + 3)
x = callee(v1)
(x + 2)
end
callee:
def callee(v)
(v + 5)
end
inline callee into caller
caller result: 12
caller:
def caller
v1 = (2 + 3)
x = (inline_callee_v = v1
(inline_callee_v + 5))
(x + 2)
end
$ ruby -Ilib bm.rb
Rehearsal -------------------------------------------
empty 0.090000 0.000000 0.090000 ( 0.083842)
plain 1.030000 0.010000 1.040000 ( 1.037302)
inlined 0.810000 0.000000 0.810000 ( 0.821394)
---------------------------------- total: 1.940000sec
user system total real
empty 0.080000 0.000000 0.080000 ( 0.084179)
plain 1.100000 0.000000 1.100000 ( 1.105742)
inlined 0.900000 0.000000 0.900000 ( 0.900799)
Read: I wrote an inliner