|
| 1 | +import {getIntParameter, getStringParameter, bindAction} from 'e2e_test_lib/benchmark_util'; |
| 2 | + |
| 3 | +var totalRows = getIntParameter('rows'); |
| 4 | +var totalColumns = getIntParameter('columns'); |
| 5 | +var benchmarkType = getStringParameter('benchmarkType'); |
| 6 | + |
| 7 | +export function main() { |
| 8 | + angular.bootstrap(document.querySelector('largetable'), ['app']); |
| 9 | +} |
| 10 | + |
| 11 | +angular.module('app', []) |
| 12 | +.config(function($compileProvider) { |
| 13 | + if ($compileProvider.debugInfoEnabled) { |
| 14 | + $compileProvider.debugInfoEnabled(false); |
| 15 | + } |
| 16 | +}) |
| 17 | +.filter('noop', function() { |
| 18 | + return function(input) { |
| 19 | + return input; |
| 20 | + }; |
| 21 | +}) |
| 22 | +.directive('largetable', function() { |
| 23 | + return { |
| 24 | + restrict: 'E', |
| 25 | + templateUrl: 'largetable-js-template.html', |
| 26 | + controller: 'DataController' |
| 27 | + }; |
| 28 | +}) |
| 29 | +.controller('DataController', function($scope) { |
| 30 | + bindAction('#destroyDom', destroyDom); |
| 31 | + bindAction('#createDom', createDom); |
| 32 | + |
| 33 | + function destroyDom() { |
| 34 | + $scope.$apply(function() { |
| 35 | + $scope.benchmarkType = 'none'; |
| 36 | + }); |
| 37 | + } |
| 38 | + |
| 39 | + function createDom() { |
| 40 | + $scope.$apply(function() { |
| 41 | + $scope.benchmarkType = benchmarkType; |
| 42 | + }); |
| 43 | + } |
| 44 | + |
| 45 | + var data = $scope.data = []; |
| 46 | + |
| 47 | + function iGetter() { return this.i; } |
| 48 | + function jGetter() { return this.j; } |
| 49 | + |
| 50 | + for (var i=0; i<totalRows; i++) { |
| 51 | + data[i] = []; |
| 52 | + for (var j=0; j<totalColumns; j++) { |
| 53 | + data[i][j] = { |
| 54 | + i: i, j: j, |
| 55 | + iFn: iGetter, |
| 56 | + jFn: jGetter |
| 57 | + }; |
| 58 | + } |
| 59 | + } |
| 60 | +}) |
| 61 | +.directive('baselineBindingTable', function() { |
| 62 | + return { |
| 63 | + restrict: 'E', |
| 64 | + link: function ($scope, $element) { |
| 65 | + var i, j, row, cell, comment; |
| 66 | + var template = document.createElement('span'); |
| 67 | + template.setAttribute('ng-repeat', 'foo in foos'); |
| 68 | + template.classList.add('ng-scope'); |
| 69 | + template.appendChild(document.createElement('span')); |
| 70 | + template.appendChild(document.createTextNode(':')); |
| 71 | + template.appendChild(document.createElement('span')); |
| 72 | + template.appendChild(document.createTextNode('|')); |
| 73 | + |
| 74 | + for (i = 0; i < totalRows; i++) { |
| 75 | + row = document.createElement('div'); |
| 76 | + $element[0].appendChild(row); |
| 77 | + for (j = 0; j < totalColumns; j++) { |
| 78 | + cell = template.cloneNode(true); |
| 79 | + row.appendChild(cell); |
| 80 | + cell.childNodes[0].textContent = i; |
| 81 | + cell.childNodes[2].textContent = j; |
| 82 | + cell.ng3992 = 'xxx'; |
| 83 | + comment = document.createComment('ngRepeat end: bar in foo'); |
| 84 | + row.appendChild(comment); |
| 85 | + } |
| 86 | + |
| 87 | + comment = document.createComment('ngRepeat end: foo in foos'); |
| 88 | + $element[0].appendChild(comment); |
| 89 | + } |
| 90 | + } |
| 91 | + }; |
| 92 | +}) |
| 93 | +.directive('baselineInterpolationTable', function() { |
| 94 | + return { |
| 95 | + restrict: 'E', |
| 96 | + link: function ($scope, $element) { |
| 97 | + var i, j, row, cell, comment; |
| 98 | + var template = document.createElement('span'); |
| 99 | + template.setAttribute('ng-repeat', 'foo in foos'); |
| 100 | + template.classList.add('ng-scope'); |
| 101 | + |
| 102 | + for (i = 0; i < totalRows; i++) { |
| 103 | + row = document.createElement('div'); |
| 104 | + $element[0].appendChild(row); |
| 105 | + for (j = 0; j < totalColumns; j++) { |
| 106 | + cell = template.cloneNode(true); |
| 107 | + row.appendChild(cell); |
| 108 | + cell.textContent = '' + i + ':' + j + '|'; |
| 109 | + cell.ng3992 = 'xxx'; |
| 110 | + comment = document.createComment('ngRepeat end: bar in foo'); |
| 111 | + row.appendChild(comment); |
| 112 | + } |
| 113 | + |
| 114 | + comment = document.createComment('ngRepeat end: foo in foos'); |
| 115 | + $element[0].appendChild(comment); |
| 116 | + } |
| 117 | + } |
| 118 | + }; |
| 119 | +}) |
0 commit comments