-
-
Save omostan/6bf7a91e0e1b5432cf74f33cb6712513 to your computer and use it in GitHub Desktop.
Angular ng-repeat Benchmark
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Post repeat directive for logging the rendering time | |
angular.module('myApp').directive('postRepeatDirective', | |
['$timeout', | |
function($timeout) { | |
return function(scope) { | |
if (scope.$first) | |
window.a = new Date(); // window.a can be updated anywhere if to reset counter at some action if ng-repeat is not getting started from $first | |
if (scope.$last) | |
$timeout(function(){ | |
console.log("## DOM rendering list took: " + (new Date() - window.a) + " ms"); | |
}); | |
}; | |
} | |
]); | |
// Use in HTML: | |
<tr ng-repeat="item in items" post-repeat-directive>…</tr> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment