Tuesday, September 18th, 2007

JPU: JavaScript CPU Monitor

Category: JavaScript

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.

Posted by Dion Almaer at 12:12 pm
5 Comments

+++--
3.3 rating from 28 votes

5 Comments »

Comments feed TrackBack URI

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 =)

Comment by Marat Denenberg — September 18, 2007

Can you give that bookmarklet another shot? TIA.

Comment by John T. — September 18, 2007

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.

Comment by Robert Schultz — September 20, 2007

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.

Comment by Shiva — October 13, 2007

Excuse my ignorance :)
But what do you mean by “WorkerPool” ?

Comment by Ariel — October 26, 2007

Leave a comment

You must be logged in to post a comment.