quantity icon indicating copy to clipboard operation
quantity copied to clipboard

Optimized unit constructor on Numeric class

Open dwbutler opened this issue 12 years ago • 5 comments

Hi,

We noticed some performance issues when working with large numbers of integers. We tracked the issue down to the #method_missing implementation defined on the Numeric class in this gem.

This patch replaces the #method_missing implementation by defining the constructors directly on Numeric.

On a side note, many of the specs are failing even on a clean master branch. Perhaps they need to be brought up to date?

Thanks!

dwbutler avatar Jun 14 '13 23:06 dwbutler

To be more specific, the performance issue started when we upgraded our app from Rails 2.3 / Ruby 1.8.7 to Rails 3.2 / Ruby 1.9.3. Apparently something in the internals is calling #method_missing on Fixnum a lot more than before.

dwbutler avatar Jul 09 '13 18:07 dwbutler

Bundler got confused by having two different gemspec files. So I removed .gemspec and left quantity.gemspec. It looked like quantity.gemspec had been modified more recently.

dwbutler avatar Jul 09 '13 18:07 dwbutler

So this is an old gem, and, it turns out, a busted one:

https://travis-ci.org/bhuga/quantity/builds/8897313

I really have no idea what the past status was--it's been a year--but it's hard for me to pull in changes when they don't pass. You can merge bhuga/stravis into your branch to get the changes that make travis work. If you're willing to fix that, or figure out which ones deserve to be pending and set them as such, I'll merge and cut a release.

bhuga avatar Jul 09 '13 18:07 bhuga

Alright, I'll give it a try.

dwbutler avatar Jul 10 '13 18:07 dwbutler

I took a look at the specs that are failing. They fall out of the scope of what I use the gem for, so I'm not clear which failures are bugs in the gem, and which are specs that need to be updated. I think I'll start a new pull request to fix the specs, and keep that discussion over there.

dwbutler avatar Jul 15 '13 19:07 dwbutler