First of all just wanted to say thank you for OpenHeatMap, it was very fun to play around with...
We were using the Canvas implementation of OpenHeatMap, and were trying to push through several frames per second of CSV data, for a dynamically updating map. Performance was poor and we were getting only about 1fps, but with a few code changes we were able to get a good result up to about 10fps, which looked smooth enough.
The issue was that the Rectangle constructor had to be called many times, and its implementation wasn't very efficient - the fix was to use prototype to create the object's functions (patch below).
Here's some profiling done (in Chrome) before our change:
Here is the patch, I will attempt to fork and commit the patch somewhere but the repo is massive so I'm having trouble getting it through our firewall.
First of all just wanted to say thank you for OpenHeatMap, it was very fun to play around with...
We were using the Canvas implementation of OpenHeatMap, and were trying to push through several frames per second of CSV data, for a dynamically updating map. Performance was poor and we were getting only about 1fps, but with a few code changes we were able to get a good result up to about 10fps, which looked smooth enough.
The issue was that the Rectangle constructor had to be called many times, and its implementation wasn't very efficient - the fix was to use prototype to create the object's functions (patch below).
Here's some profiling done (in Chrome) before our change:
77.86% 79.37% jquery.openheatmap.js:4464 Rectangle 8.93% 10.14% jquery.openheatmap.js:4771 BucketGrid.getContentsAt 3.54% 3.54% (garbage collector) 1.81% 1.87% jquery.openheatmap.js:4218 OpenHeatMap.drawImage 1.80% 93.39% jquery.openheatmap.js:3707 OpenHeatMap.drawPointBlobTile 1.73% 91.13% jquery.openheatmap.js:4766 BucketGrid.getContentsAtPoint 0.44% 0.45% jquery.openheatmap.js:4502 Rectangle.right 0.39% 0.39% jquery.openheatmap.js:4483 Rectangle.bottom 0.33% 0.33% jquery.openheatmap.js:4233 OpenHeatMap.writePixel
(etc.)
And after: 63% 50.20% jquery.openheatmap.js:4767 BucketGrid.getContentsAt 13.92% 13.92% (program) 12.34% 12.56% jquery.openheatmap.js:4218 OpenHeatMap.drawImage 7.64% 67.30% jquery.openheatmap.js:3707 OpenHeatMap.drawPointBlobTile 3.75% 55.72% jquery.openheatmap.js:4762 BucketGrid.getContentsAtPoint 1.79% 80.50% jquery.openheatmap.js:2156 OpenHeatMap.drawMapIntoMainBitmap 1.76% 1.76% jquery.openheatmap.js:4464 Rectangle 1.65% 1.65% (garbage collector) 1.32% 1.32% jquery.openheatmap.js:4233 OpenHeatMap.writePixel 1.14% 1.22% jquery.openheatmap.js:4410 Point 0.89% 0.90% jquery.openheatmap.js:4485 Rectangle.bottom 0.87% 0.92% jquery.openheatmap.js:4167 OpenHeatMap.clearCanvas 0.66% 0.68% jquery.openheatmap.js:4504 Rectangle.right 0.63% 0.75% jquery.openheatmap.js:4143 OpenHeatMap.beginDrawing (etc.)
Here is the patch, I will attempt to fork and commit the patch somewhere but the repo is massive so I'm having trouble getting it through our firewall.