-
Notifications
You must be signed in to change notification settings - Fork 199
/
ng-profile-data-change.js
37 lines (27 loc) · 834 Bytes
/
ng-profile-data-change.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
Changes data to some dummy on the scope, then runs digest cycle.
Saves CPU profile.
*/
(function profileDataChange() {
var selector = 'study-line-chart';
var propertyName = 'selectedBenchmarks';
var name = selector + ':' + propertyName;
/* global angular */
var el = angular.element(selector);
var scope = el.scope() || el.isolateScope();
console.assert(scope, 'cannot find scope from ' + name);
var property = scope[propertyName];
console.assert(property, 'missing ' + name);
function digestCycle() {
angular.element(document).injector().get('$rootScope').$apply();
}
property.foo = 'foo';
console.profile(name);
console.time(name);
digestCycle();
console.timeStamp('finished', name);
console.timeEnd(name);
console.profileEnd();
delete property.foo;
digestCycle();
}());