Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularJS + Single Core CPU = Almost 100% CPU

I've built a large AngularJS application that performed fine on until now.
My problem started when some users(with very old computers that have one CPU) complained about the application being extremely slow.

I've opened the task manager and I can see that the tab is on 70% - 100% CPU always(When using a single core CPU).

Now since this works great on stronger computers, I'm not sure I have a performance issue and if I do, I don't really know how to check this(I can't check this with performance tools on chrome).

Is there any way to handle this? To tell Angular to perform it's digest cycles less times?
Has anyone encountered a similar issue? Any tip will be great for me.

like image 340
Amir Popovich Avatar asked Sep 03 '14 10:09

Amir Popovich


People also ask

Is your CPU at 100% all the time?

Having a PC with a CPU at 100% all the time is a recipe for disaster. Like driving your car in second gear all day — engine failure is inevitable. To avoid having to replace your CPU or your entire PC, here’s how to reduce CPU usage to sustainable levels. 1. Identify the process that’s causing 100% CPU usage

Does JPA take up a lot of CPU?

One CPU is always at 100%, system is Linux Mint 20. JPA specific analysis takes a lot of CPU. Several fixes for this subsystem will be available in the next update (2020.2.1). Same is the case with me. I am using [kotlin multi module, 2020.2, ubuntu, jdk 14] combination. Even a single character type, results in super cpu usage...

How much CPU does it take to run a website?

If you’re browsing the web or using standard programs like Microsoft Office, expect CPU use between 5% and 30%. This can even include the use of graphic design programs like Adobe Photoshop and Illustrator, assuming the files you’re working on aren’t too big.

How to regulate CPU usage with AVG TuneUp?

Regulate CPU usage with AVG TuneUp. When programs on your PC fight over your CPU’s limited resources, you can reach 100% CPU usage in no time. AVG TuneUp automatically detects the apps responsible for high CPU usage and lets you deactivate them with a single click — leaving you with plenty of CPU power for the apps you actually want to use.


1 Answers

I have never seen ways to reduce the number of times cycles are called.

However there are several ways to improve the performance of your application.

First, to have an idea of the performance from your computer you may install Batarang which provide a tab for performance analysis.

Once you have this you may focus on the following:

  1. Disable the watchers that won't be use anymore
  2. Avoid ng-repeat if possible and/or use the bindonce directive
  3. Use pagination to have smaller sets of data

For more details you may refer to the following articles:

  • https://www.exratione.com/2013/12/considering-speed-and-slowness-in-angularjs/
  • https://coderwall.com/p/d_aisq
  • http://www.slideshare.net/JohnMeiss/10-astuces-pour-ameliorer-les-performances-de-son-application-angularjs-ngparis-meetup-11-meetic (Part of it is in French)
like image 136
Adlen Afane Avatar answered Sep 28 '22 07:09

Adlen Afane