unique: angular-filter vs lodash (v7)

Revision 7 of this benchmark created on


Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/3.9.3/lodash.min.js"></script>

Setup

var orders = [
        { id:1, customer: { name: 'John', id: 10 } },
        { id:2, customer: { name: 'William', id: 20 } },
        { id:3, customer: { name: 'John', id: 10 } },
        { id:4, customer: { name: 'William', id: 20 } },
        { id:5, customer: { name: 'Clive', id: 30 } }
      ];

Test runner

Ready to run.

Testing in
TestOps/sec
unique-angularFilter
angular.module('app', [])
  .controller('appCtrl', function($scope, $filter) {
    $scope.res = $filter('unique')(players,'customer.id')
  })
ready
unique-lodashFilter
angular.module('app', [])
  .controller('appCtrl', function($scope, $filter) {
    $scope.res = $filter('uniq')(players,'customer.id')
  })
  .filter('uniq', function() {
    return function(input, key) {
      return _.uniq(input, function(el) {
         return input[el];
      });
    }
  })
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.