You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
From my local comparison, equal calculations of position using ootk vs satellite.js are ~2x slower on ootk.
To Reproduce
Preparation code on ootk:
import*asootkfrom'ootk'import*assatellitefrom'satellite.js'const{ degreesToRadians }=satellite;// the only thing needed from satellite.jsconstTLE: Array<[string,string,string]>=[];// here, each item is 3 strings of a three-line element setconstsatellites=TLE.map((tle)=>{constname=tle[0].slice(2)returnnewootk.Satellite({ name,tle1: tle[1]asootk.TleLine1,tle2: tle[2]asootk.TleLine2})}).filter(sat=>sat.satrec.error===0)// tried to get the least restrictive min/max values here to not filter satellites at allconstsensor=newootk.Sensor({alt: location.altitudeasootk.Kilometers,lat: location.latitudeasootk.Degrees,lon: location.longitudeasootk.Degrees,maxAz: 360asootk.Degrees,maxEl: 180asootk.Degrees,maxRng: Infinityasootk.Kilometers,minAz: 0asootk.Degrees,minEl: 0asootk.Degrees,minRng: 0asootk.Kilometers,})
import*assatellitefrom'satellite.js'constTLE: Array<[string,string,string]>=[];// here, each item is 3 strings of a three-line element set as aboveconstsatRecs=TLE.map(tle=>satellite.twoline2satrec(tle[1],tle[2])).filter(satRec=>satRec.error===0)constgmst=satellite.gstime(date)constlocationForLib={longitude: satellite.degreesToRadians(location.longitude),latitude: satellite.degreesToRadians(location.latitude),height: location.altitude/1000}
I finally had some time to work on this. There were a few causes of the difference:
A slow caching process that I removed (see thkruz/ootk-core@d147d0c). Once I removed this, I went from 185ms for my propagation loop to 120ms.
Pure JavaScript functions vs TypeScript classes. Depending on how you transpile the code into JavaScript might impact how well the JavaScript engine caches reused functions like dpper and dspace.
I tried converting everything into functions instead of classes and didn't see any noticeable change in performance, so I reverted back for now.
The other slow thing was the recalculation of date variables (like gmst) in the Satellite object's methods. You were calculating that once with satellite.js and then reusing it for every satellite. For ootk you were recalculating it for each satellite. I updated it so you can pass j and gmst into methods like eci and skip the calculations. For users working with one satellite it will still calculate those variables automatically, but for users working with the whole catalog you can focus on performance.
I don't think your premise that it should be faster because there is less function calls from client code really makes sense. You were definitely right that there were performance issues, but there are a huge number of calculations that must happen no matter how much the user actually types. My intent is to minimize how much the user has to type - its still almost the same math.
If you are still interested, take a look and see if this is closer to what you were expecting performance wise.
Describe the bug
From my local comparison, equal calculations of position using
ootk
vssatellite.js
are ~2x slower onootk
.To Reproduce
Preparation code on
ootk
:Code to measure using
ootk
:Preparation code on
satellite.js
:Code to measure using
satellite.js
With full space-track database, takes about 150-160 ms on
ootk
vs 80 ms onsatellite.js
on my machine.Expected behavior
Performance is about the same or even better, considering less function calls from client code for
ootk
.Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: