Tuesday, September 18th, 2007
JPU: JavaScript CPU Monitor
Andrea Giammarchi has built a little experiment. His JPU is a JavaScript CPU monitor based on single threading JavaScript behaviour.
You can go to a site that uses a lot of Ajax and paste in (or bookmark) javascript:(function(s){s.type='text/javascript';s.src='http://www.3site.eu/JPU/IJPU.js';document.getElementsByTagName('head')[0].appendChild(s)})(document.createElement(’script’));
Then you can see the bars go high when you do something Ajax-y (e.g. drag and drop).

I wonder how things change when you use the WorkerPool. I put up a little example comparing running CPU intensive code inside the main browser UI thread, versus kicking it out to a WorkerPool piece of work.












Very cute. It seems the script is taking advantage of the inaccuracy of setInterval to measure load. As we all know, the more stuff you do, the more inaccurate setInterval becomes. This method would probably not work in a multi-threaded environment, since one would expect setInterval to behave better … then again, with JS, you never know =)
Can you give that bookmarklet another shot? TIA.
Very interesting. I think this has real promise as something an end-user could turn on if they report a site as being slow.
I think for an end-user though it would work better if it was a traffic light. Green, Yellow, Red.
So have them switch on the traffic light and have them inform you what part of the application (what actions, areas, data, etc) they are dealing with when the traffic light turns red.
It would make it a lot easier to get answers out of users about where things are slow.
This is a beauty! It does give a crude picture of the CPU activity caused by the script in the page. Clever way to take advantage of setInterval()’s inconsistency.
Excuse my ignorance :)
But what do you mean by “WorkerPool” ?