2 ms·
Does anyone have any idea why the mouse-over examples are a more CPU intensive task for Firefox? On my laptop, moving the mouse a lot results in 15% CPU usage,
by vanderZwan 13y ago
Does anyone have any idea why the mouse-over examples are a more CPU intensive task for Firefox? On my laptop, moving the mouse a lot results in 15% CPU usage, and if I jitter it fast enough it maxes out at 22%. That won't lock up the browser if I'm not doing anything else but still feels like it will drain the laptop battery notably faster with intensive use, if you catch my drift.
With Chrome I can't get it above 4%. IE 10 is somewhere in the middle with 10% (and also has a bug when resizing the window, giving Y values like 2236.65990234375, with the fraction part being constant).
EDIT: Both Opera 12 and Opera 15: 6 to 8%
Also, the second/third examples seem a bit laggy with all browsers: if I shake the mouse quickly the numbers keep updating for a while after I stop. I guess that this is because instead of showing the most recent value it shows all the location values, but the screen updates are slower than the mouse updates?
Either way, when the mouse stops moving while the numbers still update, Firefox only takes 6% of the CPU. Not sure if that clarifies anything, but it might help identify the cause.
- swannodette 13y agoI don't think you can come to any conclusions from these numbers. I see the exact same CPU utilization across browsers if I replicate the styles and write this JavaScript instead: var loc = document.getElementById("location"); window.addEventListener("mousemove", function(e) { loc.innerHTML = e.pageX + ", " + e.pageY; }); Which is saying something, the ClojureScript is doing a lot more work and it ain't slow ;) I suspect all the cost is from repainting large areas at the speed of mouse movement. But the mouse examples are for illustration - in production code you'll probably want to throttle (which would avoid piling up the repaints you observed on slower machines) as well as address the IE 10 edge case.
- vanderZwan 13y agoWell, my question was why one browser was slower than the other - I didn't expect ClojureScript to be the cause of the problem. I was just curious about what might cause the difference. > I suspect all the cost is from repainting large areas at the speed of mouse movement. I'm not really a web dev, but isn't this a reflow, not a repaint? Could that be the reason for the difference in performance too? What happens if you use canvas instead of changing a div? BTW, I forgot to mention this in the previous comment, but: this is pretty cool! I echo the "being spoilt by Go" sentiments of others, so I'm happy to see this library.