aphalo / ooacquire

Acquire spectral data and control array spectrometers from Ocean Optics from within R
https://docs.r4photobiology.info/ooacquire
1 stars 0 forks source link

bleed_nas() seems to be slowing-down HDR processing #13

Closed aphalo closed 10 months ago

aphalo commented 10 months ago

Profiling shows that a lot of time is spent in this function. It has nested for loops, one of them walking pixel by pixel the whole spectrum.

I think using rle() instead of the inner loop one could speed up this function a lot.

Without HDR it takes some 72 ms per spectrum, with HDR 190 ms.

aphalo commented 10 months ago

Done. It was really a major bottleneck. Using rle() did the trick together with aborting early in the absence of any NAs. With HDR conversion from RAW to IRRAD the total time went from 190 ms to 20 ms, with no HDR, the total time decreased by 2/3.