Skip to content

Conversation

etehtsea
Copy link
Contributor

Kinda microoptimization, but why not?

require 'benchmark'

n = 10_000_000

Benchmark.bm do |x|
  x.report('/') { n.times { 1.0 / 0.0 } }
  x.report('const') { n.times { Float::INFINITY } }
end
       user     system      total        real
/  0.920000   0.010000   0.930000 (  0.913245)
const  0.500000   0.000000   0.500000 (  0.506287)

@senny
Copy link
Member

senny commented Aug 22, 2013

yea it is pretty micro but I like the fact that Float::Infinity is actually more expressive than the division. Let's wait for the travis build but it looks good to me.

@carlosantoniodasilva
Copy link
Member

👍

senny added a commit that referenced this pull request Aug 22, 2013
[PG adapter] Use infinity const
@senny senny merged commit 998d9c8 into rails:master Aug 22, 2013
@senny
Copy link
Member

senny commented Aug 22, 2013

Thank you for your contribution 💛

@etehtsea etehtsea deleted the inf branch August 22, 2013 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants