Kurt StephensNerd Up! | ||||||||
Ruby 1.8: Improved Rational performance by 15%Kurt on Wed, 2009-12-23 21:27.
This should also speed up DateTime. This will not help 1.9 performance. The attached file is based on MRI 1.8.6 rational.rb.
> ruby rational_performance.rb
user system total real
test_it 32.930000 3.030000 35.960000 ( 35.971832)
test_it 33.840000 2.910000 36.750000 ( 36.758585)
test_it ks_rational 29.110000 2.460000 31.570000 ( 31.572762)
Overview:
MRI 1.8.7 patch to follow shortly.
$ irb irb(main):001:0>Submitted by Bruce (not verified) on Mon, 2010-01-25 23:31.
$ irb
irb(main):001:0> require “ks_rational.rb”
=> true
irb(main):002:0> r = Rational.new! 0, 0
=> Rational0, 0
irb(main):003:0> r.zero?
=> true
irb(main):004:0> r = Rational(0, 0)
ZeroDivisionError: denominator is zero
from ks_rational.rb:76:in `reduce’
from ks_rational.rb:39:in `Rational’
from (irb):2
I’d suggest a warning in the RDoc for » reply
|
||||||||
Recent comments
9 weeks 2 days ago
19 weeks 3 days ago
38 weeks 1 day ago
1 year 2 weeks ago
1 year 35 weeks ago
1 year 48 weeks ago
1 year 50 weeks ago
1 year 51 weeks ago
1 year 51 weeks ago
1 year 51 weeks ago