|
5 | 5 |
|
6 | 6 | // assumes the angular application is at least around the document's body
|
7 | 7 |
|
8 | | -/* global angular, performance */ |
9 | | -angular.element(document.body).injector().invoke(function timeApply($rootScope) { |
10 | | - console.profile('$apply'); |
11 | | - var started = performance.now(); |
12 | | - $rootScope.$apply(); |
13 | | - var takes = performance.now() - started; |
14 | | - console.log('idle $apply takes', takes, 'ms'); |
15 | | - console.profileEnd(); |
16 | | - return takes; |
17 | | -}); |
| 8 | +/* global performance */ |
| 9 | +(function profileIdleTiming(angular) { |
| 10 | + |
| 11 | + function timeApply($rootScope) { |
| 12 | + console.profile('$apply'); |
| 13 | + var started = performance.now(); |
| 14 | + $rootScope.$apply(); |
| 15 | + var takes = performance.now() - started; |
| 16 | + console.log('idle $apply takes', takes, 'ms'); |
| 17 | + console.profileEnd(); |
| 18 | + return takes; |
| 19 | + } |
| 20 | + timeApply.$inject = ['$rootScope']; |
| 21 | + |
| 22 | + angular.element(document.body).injector().invoke(timeApply); |
| 23 | +}(window.angular)); |
0 commit comments