astronomy icon indicating copy to clipboard operation
astronomy copied to clipboard

Kotlin: Astronomy.seasons is slow

Open ebraminio opened this issue 2 years ago • 1 comments

I think given the way seasons are calculated the following issue can be expected but I'm describing it anyway so you may want to fix or close it,

I'm running for (i in 1583..3667) Astronomy.seasons(i) and in multiple runs I get ~650ms result but equivalent code using this library https://github.com/persian-calendar/equinox which I used to maintain with the following code

for (i in 1583..3667) {
  Equinox.NORTHWARD_EQUINOX.inYear(i)
  Equinox.NORTHERN_SOLSTICE.inYear(i)
  Equinox.SOUTHWARD_EQUINOX.inYear(i)
  Equinox.SOUTHERN_SOLSTICE.inYear(i)
}

gives 60ms and it doesn't do any caching internally. I understand you directly calculate sun ecliptic longitude but apparently faster ways exists also.

ebraminio avatar Apr 07 '22 21:04 ebraminio

That is much faster, definitely! I will come back and look at this, after the first pass of getting all the Kotlin code translated and working. I will keep this issue open so I won't forget.

cosinekitty avatar Apr 07 '22 21:04 cosinekitty

@ebraminio : Is the speed of the seasons function still a problem?

cosinekitty avatar Oct 04 '22 01:10 cosinekitty

No, I'm caching it anyway so not much an issue anyway so let me close this, thanks :)

ebraminio avatar Oct 04 '22 05:10 ebraminio