Skip to content

decimal performance #5650

@stevenjwolfman

Description

@stevenjwolfman

Environment

Provide at least:

  • jruby 9.2.5.0 (2.5.0) 2018-12-06 6d5a228 Java HotSpot(TM) 64-Bit Server VM 25.121-b13 on 1.8.0_121-b13 +jit [darwin-x86_64]
  • Darwin ip-192-168-30-11.ec2.internal 18.0.0 Darwin Kernel Version 18.0.0: Wed Aug 22 20:13:40 PDT 2018; root:xnu-4903.201.2~1/RELEASE_X86_64 x86_64

When implementing the Haversine formula (http://stackoverflow.com/a/12969617/3443587), if I converted latitude and longitude to a decimal before running it, it took more than 150 times longer than if I left it as a float. This seems excessive and an opportunity for tuning.

This slow performance was not found in JRuby 1.7

For just multiplying simple numbers
irb(main):002:0> Benchmark.measure{1000.times{5.05.0}}
#<Benchmark::Tms:0x41cec7b0 @stime=0.0, @Label="", @CsTime=0.0, @real=0.000554911996005103, @ToTal=0.0, @cutime=0.0, @utime=0.0>
irb(main):003:0> Benchmark.measure{1000.times{5.0.to_d
5.0.to_d}}
#<Benchmark::Tms:0x6773c073 @stime=0.009999999999999787, @Label="", @CsTime=0.0, @real=0.015367278996563982, @ToTal=0.04999999999999183, @cutime=0.0, @utime=0.03999999999999204>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions