I wrote an inliner

Eric Hodel | Wed, 27 Jun 2007 07:35:00 GMT

Posted in , ,

$ 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)
no comments

Comments RSS FEED

Comments are disabled