Search code examples
angularangular7angular2-changedetectionangular-changedetection

Angular performace - OnPush increases num of cycles


im trying to measure the performance differences in change detection strategies.

i've added the angular profiler, and checked with Default and then added onPush to most of our components and these are the results: (development mode)

Default: { msPerTick: 25+-, numTicks: 18+- } onPush: { msPerTick: 2+-, numTicks 220+- }

as you can see the msPerTick has reduced significantly, but the number of cycles is 10 times bigger. the more components i change to onPush, so the ms reduces and numTicks increases.

i want to know if it's ok and normal, and if not what can cause that?

Extra details: angular 7, im using lazy load modules(with routing). app.component is on default strategy. im checking it on the biggest module. big.module has big.home component (default) with child components (onPush)


Solution

  • Update: i figured it out, the timeChangeDetection function runs for half a second and tries to do as many cycles as it can. so the wanted situation it as many numTicks as possible.