1+ var app = angular . module ( 'largetableBenchmark' , [ ] ) ;
2+
3+ app . filter ( 'noop' , function ( ) {
4+ return function ( input ) {
5+ return input ;
6+ } ;
7+ } ) ;
8+
9+ app . controller ( 'DataController' , function ( $scope , $rootScope ) {
10+ var totalRows = 1000 ;
11+ var totalColumns = 20 ;
12+
13+ var data = $scope . data = [ ] ;
14+ $scope . digestDuration = '?' ;
15+ $scope . numberOfBindings = totalRows * totalColumns * 2 + totalRows + 1 ;
16+ $scope . numberOfWatches = '?' ;
17+
18+ function iGetter ( ) { return this . i ; }
19+ function jGetter ( ) { return this . j ; }
20+
21+ for ( var i = 0 ; i < totalRows ; i ++ ) {
22+ data [ i ] = [ ] ;
23+ for ( var j = 0 ; j < totalColumns ; j ++ ) {
24+ data [ i ] [ j ] = {
25+ i : i , j : j ,
26+ iFn : iGetter ,
27+ jFn : jGetter
28+ } ;
29+ }
30+ }
31+
32+ var previousType ;
33+
34+ benchmarkSteps . push ( {
35+ name : 'destroy' ,
36+ fn : function ( ) {
37+ $scope . $apply ( function ( ) {
38+ previousType = $scope . benchmarkType ;
39+ $scope . benchmarkType = 'none' ;
40+ } ) ;
41+ }
42+ } ) ;
43+
44+ benchmarkSteps . push ( {
45+ name : 'create' ,
46+ fn : function ( ) {
47+ $scope . $apply ( function ( ) {
48+ $scope . benchmarkType = previousType ;
49+ } ) ;
50+ }
51+ } ) ;
52+
53+ benchmarkSteps . push ( {
54+ name : '$apply' ,
55+ fn : function ( ) {
56+ $rootScope . $apply ( ) ;
57+ }
58+ } ) ;
59+ } ) ;
60+
61+ var fn = function ( ) { return 'x' } ;
62+
63+
64+ app . directive ( 'baselineBindingTable' , function ( ) {
65+ return {
66+ restrict : 'E' ,
67+ link : function ( $scope , $element ) {
68+ var i , j , row , cell , comment ;
69+ var template = document . createElement ( 'span' ) ;
70+ template . setAttribute ( 'ng-repeat' , 'foo in foos' ) ;
71+ template . classList . add ( 'ng-scope' ) ;
72+ template . appendChild ( document . createElement ( 'span' ) ) ;
73+ template . appendChild ( document . createTextNode ( ':' ) ) ;
74+ template . appendChild ( document . createElement ( 'span' ) ) ;
75+ template . appendChild ( document . createTextNode ( '|' ) ) ;
76+
77+ for ( i = 0 ; i < 1000 ; i ++ ) {
78+ row = document . createElement ( 'div' ) ;
79+ $element [ 0 ] . appendChild ( row ) ;
80+ for ( j = 0 ; j < 20 ; j ++ ) {
81+ cell = template . cloneNode ( true ) ;
82+ row . appendChild ( cell ) ;
83+ cell . childNodes [ 0 ] . textContent = i ;
84+ cell . childNodes [ 2 ] . textContent = j ;
85+ cell . ng3992 = 'xxx' ;
86+ comment = document . createComment ( 'ngRepeat end: bar in foo' ) ;
87+ row . appendChild ( comment ) ;
88+ }
89+
90+ comment = document . createComment ( 'ngRepeat end: foo in foos' ) ;
91+ $element [ 0 ] . appendChild ( comment ) ;
92+ }
93+ }
94+ } ;
95+ } ) ;
96+
97+
98+ app . directive ( 'baselineInterpolationTable' , function ( ) {
99+ return {
100+ restrict : 'E' ,
101+ link : function ( $scope , $element ) {
102+ var i , j , row , cell , comment ;
103+ var template = document . createElement ( 'span' ) ;
104+ template . setAttribute ( 'ng-repeat' , 'foo in foos' ) ;
105+ template . classList . add ( 'ng-scope' ) ;
106+
107+ for ( i = 0 ; i < 1000 ; i ++ ) {
108+ row = document . createElement ( 'div' ) ;
109+ $element [ 0 ] . appendChild ( row ) ;
110+ for ( j = 0 ; j < 20 ; j ++ ) {
111+ cell = template . cloneNode ( true ) ;
112+ row . appendChild ( cell ) ;
113+ cell . textContent = '' + i + ':' + j + '|' ;
114+ cell . ng3992 = 'xxx' ;
115+ comment = document . createComment ( 'ngRepeat end: bar in foo' ) ;
116+ row . appendChild ( comment ) ;
117+ }
118+
119+ comment = document . createComment ( 'ngRepeat end: foo in foos' ) ;
120+ $element [ 0 ] . appendChild ( comment ) ;
121+ }
122+ }
123+ } ;
124+ } ) ;
125+
126+
127+
128+ /*
129+
130+ the fastest
131+ 240/44
132+
133+ app.directive('baselineTable', function() {
134+ return function($scope, $element) {
135+ var i, j, row, cell;
136+
137+ for (i = 0; i < 1000; i++) {
138+ row = document.createElement('div');
139+ for (j = 0; j < 20; j++) {
140+ cell = document.createElement('span');
141+ cell.textContent = '' + i + ':' + j;
142+ row.appendChild(cell);
143+ }
144+ $element[0].appendChild(row);
145+ }
146+ };
147+ });
148+
149+ */
150+
151+ /*
152+ with comments and expando
153+ 232/90
154+
155+ app.directive('baselineTable', function() {
156+ return function($scope, $element) {
157+ var i, j, row, cell, comment;
158+
159+ for (i = 0; i < 1000; i++) {
160+ row = document.createElement('div');
161+ $element[0].appendChild(row);
162+ for (j = 0; j < 20; j++) {
163+ cell = document.createElement('span');
164+ row.appendChild(cell);
165+ cell.textContent = '' + i + ':' + j;
166+ cell.ng3992 = 'xxx';
167+ comment = document.createComment('ngRepeat end: bar in foo');
168+ row.appendChild(comment);
169+ }
170+
171+ comment = document.createComment('ngRepeat end: foo in foos');
172+ $element[0].appendChild(comment);
173+ }
174+ };
175+ });
176+
177+ */
0 commit comments