_.values

JavaScript performance comparison

Test case created by liuyl

Preparation code

<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.1/underscore-min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/1.3.1/lodash.min.js
">
</script>
<script>
var lodash = _.noConflict();

_.mixin({
  'myvalues': function(obj) {
    return _.map(_.keys(obj), function(key){
      return obj[key];
    });
  }
});
</script>
<script>
Benchmark.prototype.setup = function() {
    var _ = window._,
        lodash = window.lodash,
        object = {};
       
    _.times(100, function(n) {
      object['key' + n] = 'value' + n;
    });
};
</script>

Preparation code output

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
original
_.values(object);
pending…
my implement
_.myvalues(object);
pending…
lodash
lodash.values(object);
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment