Closed oleg-alexandrov closed 2 years ago
I'm curious how much time is taken by the lagrangeitnerp function vs applying the adjustments.
It is the lagrange interpolation which takes up almost all the time. I will look later into optimizing that too, as there are too many repeated multiplications which could be done just once.
If the adjustments are non-zero, one has to compute the velocity in order to find the adjusted position. So this optimization trick works only if both there is no need for velocity and there are no adjustments. Hence, these can't be separated.
I addressed the above.
I made a 23% speed improvement in the linescan sensor logic, without changing the results. This relies on avoiding computing the interpolated velocity and applying adjustments when those are not used by the caller.
To verify this, run:
cd usgscsm/build time ./usgscsm_cam_test --model ../tests/data/toughLroNacLineScan.json --sample-rate 1
before and after applying the fix. On my machine the run time is 155 seconds before the fix, and 118 seconds after it. Granted, not a huge improvement, but it is notable, and the code changes are small.