This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree 3 files changed +116
-0
lines changed
3 files changed +116
-0
lines changed Original file line number Diff line number Diff line change
1
+ "use strict" ;
2
+
3
+ /* globals angular, benchmarkSteps */
4
+
5
+ var app = angular . module ( 'ngOptionsBenchmark' , [ ] ) ;
6
+
7
+ app . config ( function ( $compileProvider ) {
8
+ if ( $compileProvider . debugInfoEnabled ) {
9
+ $compileProvider . debugInfoEnabled ( false ) ;
10
+ }
11
+ } ) ;
12
+
13
+
14
+
15
+ app . controller ( 'DataController' , function ( $scope , $element ) {
16
+ $scope . items = [ ] ;
17
+ $scope . count = 10000 ;
18
+
19
+ function changeOptions ( ) {
20
+ $scope . items = [ ] ;
21
+ for ( var i = 0 ; i < $scope . count ; ++ i ) {
22
+ $scope . items . push ( {
23
+ id : i ,
24
+ label : 'item-' + i ,
25
+ group : 'group-' + i % 100
26
+ } ) ;
27
+ }
28
+ }
29
+
30
+ var selectElement = $element . find ( 'select' ) ;
31
+ console . log ( selectElement ) ;
32
+
33
+
34
+ benchmarkSteps . push ( {
35
+ name : 'add-options' ,
36
+ fn : function ( ) {
37
+ $scope . $apply ( function ( ) {
38
+ $scope . count = 10000 ;
39
+ changeOptions ( ) ;
40
+ } ) ;
41
+ }
42
+ } ) ;
43
+
44
+ benchmarkSteps . push ( {
45
+ name : 'set-model-1' ,
46
+ fn : function ( ) {
47
+ $scope . $apply ( function ( ) {
48
+ $scope . x = $scope . items [ 1000 ] ;
49
+ } ) ;
50
+ }
51
+ } ) ;
52
+
53
+ benchmarkSteps . push ( {
54
+ name : 'set-model-2' ,
55
+ fn : function ( ) {
56
+ $scope . $apply ( function ( ) {
57
+ $scope . x = $scope . items [ 10 ] ;
58
+ } ) ;
59
+ }
60
+ } ) ;
61
+
62
+ benchmarkSteps . push ( {
63
+ name : 'remove-options' ,
64
+ fn : function ( ) {
65
+ $scope . count = 100 ;
66
+ changeOptions ( ) ;
67
+ }
68
+ } ) ;
69
+
70
+ benchmarkSteps . push ( {
71
+ name : 'add-options' ,
72
+ fn : function ( ) {
73
+ $scope . $apply ( function ( ) {
74
+ $scope . count = 10000 ;
75
+ changeOptions ( ) ;
76
+ } ) ;
77
+ }
78
+ } ) ;
79
+
80
+ benchmarkSteps . push ( {
81
+ name : 'set-view-1' ,
82
+ fn : function ( ) {
83
+ selectElement . val ( '2000' ) ;
84
+ selectElement . triggerHandler ( 'change' ) ;
85
+ }
86
+ } ) ;
87
+
88
+ benchmarkSteps . push ( {
89
+ name : 'set-view-2' ,
90
+ fn : function ( ) {
91
+ selectElement . val ( '1000' ) ;
92
+ selectElement . triggerHandler ( 'change' ) ;
93
+ }
94
+ } ) ;
95
+ } ) ;
Original file line number Diff line number Diff line change
1
+ module . exports = function ( config ) {
2
+ config . set ( {
3
+ scripts : [ {
4
+ id : 'angular' ,
5
+ src : '/build/angular.js'
6
+ } ,
7
+ {
8
+ src : 'app.js' ,
9
+ } ]
10
+ } ) ;
11
+ } ;
Original file line number Diff line number Diff line change
1
+ < div ng-app ="ngOptionsBenchmark " ng-cloak >
2
+ < div ng-controller ="DataController ">
3
+ < div class ="container-fluid ">
4
+ < p >
5
+ Tests the execution of ng-options for rendering during model and option updates.
6
+ </ p >
7
+ < select ng-model ="x " ng-options ="a as a.label group by a.group for a in items track by a.id "> </ select >
8
+ </ div >
9
+ </ div >
10
+ </ div >
You can’t perform that action at this time.
0 commit comments