astronomy
astronomy copied to clipboard
Kotlin: Astronomy.seasons is slow
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.
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.
@ebraminio : Is the speed of the seasons
function still a problem?
No, I'm caching it anyway so not much an issue anyway so let me close this, thanks :)