keenerd / rtl-sdr-misc

A bucket of various work-in-progress rtl-sdr ideas.
208 stars 171 forks source link

Make heatmap.py faster #17

Open bogdanr opened 7 years ago

bogdanr commented 7 years ago

I have a 6G csv file and the heatmap is processing for hours. It would be nice if we could make use of multiple threads to make the heatmap script run faster.

whyrlpool commented 5 years ago

if you want to get a performance increase without changing any of the code, I've found it runs a smidgen faster (around 4x the speed) under pypy, yet there seems to be some inconsistency with the data output, which I'm yet to track down, but I think it's to do with the final line of pixels.

root@twelve:/home/pi/SoapySDR/build# time pypy ./heatmap.py /home/pi/output13.txt output13.png
loading
x: 20000, y: 214, z: (-130.909000, -61.927300)
drawing
labeling
saving

real    0m53.029s
user    0m52.658s
sys     0m0.330s
root@twelve:/home/pi/SoapySDR/build# md5sum output13.png
a7056db36a553099f4de77a7aabbf247  output13.png
root@twelve:/home/pi/SoapySDR/build# time python3 ./heatmap.py /home/pi/output13.txt output13.png
loading
x: 20000, y: 214, z: (-130.909000, -61.927300)
drawing
labeling
saving

real    4m4.220s
user    4m3.088s
sys     0m0.251s
root@twelve:/home/pi/SoapySDR/build# md5sum output13.png
5e1d17efccce25786dc54fddc476f8c7  output13.png

root@twelve:/home/pi/SoapySDR/build# du -h output13.png ../../output13.txt
2.1M    output13.png
42M     ../../output13.txt

If you want to spread the process across multiple cores you could use the slicing arguments (--low --high --begin --end) to specify what part of the graph you want to compute, and then slice the image back together with imagemagick, but I had issues with dimensions greater than UINT32_MAX so ymmv