美文网首页
Enable Angular Profiler

Enable Angular Profiler

作者: forks1990 | 来源:发表于2018-09-28 16:00 被阅读0次

Change bootstrap code in your main.ts file:

platformBrowserDynamic().bootstrapModule(AppModule).then(
  module => {
    // Enable profile tools in development mode, run:
    //
    //   ng.profiler.timeChangeDetection()
    //
    // In browser develop tools console.
    if (!environment.production) {
      let applicationRef = module.injector.get(ApplicationRef);
      let appComponent = applicationRef.components[0];
      enableDebugTools(appComponent);
    }
  }
).catch(err => console.log(err));

Open browser developer tools run: ng.profiler.timeChangeDetection(), you'll get something like:

> ng.profiler.timeChangeDetection()
platform-browser.js:2201 ran 4308 change detection cycles
platform-browser.js:2202 0.12 ms per check
ChangeDetectionPerfRecord {msPerTick: 0.11606313834726091, numTicks: 4308}

Helpful to find out angular change detection performance, combine with browser javascript profiler to find out which component is too slow.

相关文章

网友评论

      本文标题:Enable Angular Profiler

      本文链接:https://www.haomeiwen.com/subject/geepoftx.html