K
klochner
sorry for the cross-post from RoR, but I actually think this is more
of a ruby question.
I got sidetracked while benchmarking ruby factorial code:
http://rosettacode.org/wiki/Factorial#Ruby
I put all that code into test_fact.rb and ran with:
here are the respective results:
user system total real # ruby
recursive: 8.660000 0.040000 8.700000 ( 8.888191)
iterative: 6.770000 0.030000 6.800000 ( 6.892491)
functional: 6.240000 0.030000 6.270000 ( 6.334801)
user system total real # rails_f
recursive: 10.140000 0.070000 10.210000 ( 10.760008)
iterative: 8.750000 0.050000 8.800000 ( 9.050677)
functional: 8.200000 0.040000 8.240000 ( 8.477966)
user system total real # rails_m
recursive: 17.400000 0.170000 17.570000 ( 17.792121)
iterative: 15.730000 0.140000 15.870000 ( 16.233311)
functional: 15.450000 0.160000 15.610000 ( 16.245557)
I profiled it as well and the function calls were identical, just
slower.
This feels like a ruby issue that rails brings out in spades, I'm
wondering if anyone here has some insight as to what's going on.
- kevin
of a ruby question.
I got sidetracked while benchmarking ruby factorial code:
http://rosettacode.org/wiki/Factorial#Ruby
I put all that code into test_fact.rb and ran with:
ruby test_fact.rb
rails runner test_fact.rb #from a fresh rails app
rails runner test_fact.rb #from a mature rails app
here are the respective results:
user system total real # ruby
recursive: 8.660000 0.040000 8.700000 ( 8.888191)
iterative: 6.770000 0.030000 6.800000 ( 6.892491)
functional: 6.240000 0.030000 6.270000 ( 6.334801)
user system total real # rails_f
recursive: 10.140000 0.070000 10.210000 ( 10.760008)
iterative: 8.750000 0.050000 8.800000 ( 9.050677)
functional: 8.200000 0.040000 8.240000 ( 8.477966)
user system total real # rails_m
recursive: 17.400000 0.170000 17.570000 ( 17.792121)
iterative: 15.730000 0.140000 15.870000 ( 16.233311)
functional: 15.450000 0.160000 15.610000 ( 16.245557)
I profiled it as well and the function calls were identical, just
slower.
This feels like a ruby issue that rails brings out in spades, I'm
wondering if anyone here has some insight as to what's going on.
- kevin