JuanIrache / gopro-telemetry

Reads telemetry from the GPMF track in GoPro cameras (Hero5 and later) and converts it to multiple formats
https://tailorandwayne.com/gopro-telemetry-extractor/
MIT License
310 stars 56 forks source link

Optimized performance by replacing slice method with subarray #216

Closed g3ncl closed 5 months ago

g3ncl commented 5 months ago

Hi, I think I have identified the reason behind the performance difference between running in browser vs Node.js. Unlike TypedArray.slice(), which generates a new copy of the sliced portion, Buffer.slice() produces a new buffer that shares memory with the original buffer, essentially behaving in the same way as the subarray() method. This discrepancy is why Buffer.slice() has been deprecated.

I ran some tests using three different videos:

File Size Version Execution Time (s)
556 MB Original 4.731
Updated 1.591
1.8 GB Original 37.730
Updated 4.596
6.1 GB Original 396.933
Updated 15.095
JuanIrache commented 5 months ago

Thanks Claudio. That's great!