-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
`BigDecimal` was introduced early in the project from my belief that high accuracy was needed. It turns out that the number of digits in floats are enough to keep a precision up to 0.0001 arcseconds in most calculations. Using `BigDecimal` has a cost over the overall performance of the library. If it is not absolutely necessary for the calculations, it's better not to use it. Calculations are performed 11 times faster using only floats, for the same precision (see benchmark below). ### Benchmark The benchmark simply executes usual calculations enabled by the library at the moment, many times. ```rb Benchmark.bmbm do |x| x.report do 10_000.times do time = Time.utc(2023, 2, 17, 11, 0, 0) epoch = Astronoby::Epoch.from_time(time) observer = Astronoby::Observer.new( latitude: Astronoby::Angle.from_degrees(38), longitude: Astronoby::Angle.from_degrees(-78) ) sun = Astronoby::Sun.new(epoch: epoch) sun .apparent_ecliptic_coordinates .to_apparent_equatorial(epoch: epoch) .to_horizontal( time: time, latitude: observer.latitude, longitude: observer.longitude ) sun.rising_time(observer: observer) sun.rising_azimuth(observer: observer).str(:dms) sun.setting_time(observer: observer) sun.setting_azimuth(observer: observer).str(:dms) year = 2024 Astronoby::EquinoxSolstice.march_equinox(year) Astronoby::EquinoxSolstice.june_solstice(year) end end end ``` ``` user system total real with BigDecimal 61.342663 0.351669 61.694332 (61.892873) without BigDecimal 5.286487 0.004743 5.291230 (5.308093) ```
- Loading branch information
1 parent
fdb16bc
commit e3d862f
Showing
15 changed files
with
89 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
require "bigdecimal/math" | ||
|
||
module Astronoby | ||
module Util | ||
module Trigonometry | ||
|
Oops, something went wrong.