Skip to content

Commit

Permalink
chore(benchmarks): add $watchCollection tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jbedard committed Jun 28, 2017
1 parent 423acc2 commit a772b94
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
15 changes: 15 additions & 0 deletions benchmarks/parsed-expressions-bp/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,21 @@ app.directive('bmPeWatch', function() {
};
});

//Executes the specified expression as a collection watcher
app.directive('bmPeWatchCollection', function() {
return {
restrict: 'A',
compile: function($element, $attrs) {
$element.text($attrs.bmPeWatchCollection);
return function($scope, $element, $attrs) {
$scope.$watchCollection($attrs.bmPeWatchCollection, function(val) {
$element.text(val);
});
};
}
};
});

app.controller('DataController', function($scope, $rootScope) {
var totalRows = 10000;

Expand Down
27 changes: 27 additions & 0 deletions benchmarks/parsed-expressions-bp/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@
<input type="radio" ng-model="expressionType" value="arrayLiterals" id="arrayLiterals">
<label for="arrayLiterals">Array Literals</label>
</li>

<li>
<input type="radio" ng-model="expressionType" value="watchCollection" id="watchCollection">
<label for="watchCollection">$watchCollection</label>
</li>

<li>
<input type="radio" ng-model="expressionType" value="watchCollectionLiterals" id="watchCollectionLiterals">
<label for="watchCollectionLiterals">$watchCollection Literals</label>
</li>
</ul>

<!--
Expand Down Expand Up @@ -220,6 +230,23 @@
<span bm-pe-watch="[0, 1, 2, rowIdx]"></span>
<span bm-pe-watch="[0, 1, 2, 3, rowIdx]"></span>
</li>

<li ng-switch-when="watchCollection" ng-repeat="(rowIdx, row) in data">
<span bm-pe-watch-collection="data"></span>
<span bm-pe-watch-collection="row.keys"></span>
<span bm-pe-watch-collection="thisProbablyDoesntHaveAValue"></span>
</li>

<li ng-switch-when="watchCollectionLiterals" ng-repeat="(rowIdx, row) in ::data">
<span bm-pe-watch-collection="[rowIdx, row]"></span>
<span bm-pe-watch-collection="[rowIdx, row, num0, str0, date0, obj, g, h, i, j, k, l, m, n, o, p]"></span>
<span bm-pe-watch-collection="{a: rowIdx, b: row, c: num0, d: str0, e: date0, f: obj, g: g, h: h, i: i, j: j, k: k, l: l, m: m, n: n, o: o, p: p}"></span>

<!-- primitive/valueOf-compatible -->
<span bm-pe-watch-collection="[rowIdx, row]"></span>
<span bm-pe-watch-collection="[rowIdx, num0, str0, date0, date1, h, i, j, k, l, m, n, o, p]"></span>
<span bm-pe-watch-collection="{a: rowIdx, c: num0, d: str0, e: date0, g: date1, h: h, i: i, j: j, k: k, l: l, m: m, n: n, o: o, p: p}"></span>
</li>
</ul>
</div>
</div>
Expand Down

0 comments on commit a772b94

Please sign in to comment.