1

I try to optimize my program which is taking over 107% of CPU usage on Ubuntu for a specific page and less for the other ones (70% - also showing multiple gages but differently - , 5% showing other data (which is not showing gages), etc...).

My page is showing multiple gages using justgage.js which is using raphael.js

I try to debug using the Google Developpers Tools, but when I use the "Collect Javascript CPU Profile" nothing makes me believe that something is taking that CPU. The only thing I see is 100% for the function "Program"

Do you have any idea on how I could debug this? Or what could take the CPU like this?

Note that the CPU using "top" command on ubuntu is giving me the same result when using firefox or chrome.

sincos
  • 127
  • 2
  • 18

1 Answers1

-2

There is nothing wrong with 100% CPU usage unless the page is taking too long to load, because if the CPU is running your code at all, it is running it at full speed.

So the real question is, does it take too long? If so, there's a simple way to find out why.

If you can use the Chrome Debugger, you can just hit "Pause" during the time it appears to be hung, as in this post by @Tigraine. Display the call stack, read it, and figure out why it is doing each thing on the stack, because if it's wasting much time, as a percent, you're likely to catch it in the act. You might have to do this a few times before you see the problem. The worse it is, the fewer times you have to look.

That's this technique, and it is really very different from trying to collect measurements.

Community
  • 1
  • 1
Mike Dunlavey
  • 40,059
  • 14
  • 91
  • 135
  • It isn't too long. I used some tools to slow down the load time (example, minify .js and .css, etc...) The program is queued (with settimeout ) for the next refresh when the CPU is more than 100% ( by 107 to 110 %). So no work is really done (what I think). But I'm really not familiar with the CPU usage So, this will not slow down the other tasks on the computer having such a high CPU? The application itself will probably be the only thing that will run on this computer, but suppose they want to use the computer for other purpose? The other tasks will not likely to be slower ? – sincos Aug 15 '15 at 20:16