underscore shuffle (v6)

Revision 6 of this benchmark created on


Preparation HTML

<script src="//rawgit.com/megawac/underscore/shuffle/underscore.js">
</script>
<script>var megascore = _.noConflict();</script>
<script src="//rawgit.com/lodash/lodash/master/dist/lodash.js"></script>
<script>var lodash = _.noConflict();</script>
<script src="http://rawgit.com/jashkenas/underscore/master/underscore.js">
</script>

<script>
megascore.shuffle2 = function(obj) {
    var arr = _.toArray(obj);
    var length = arr.length;
    while (length--) {
      var rand = _.random(0, length);
      var t = arr[length];
      arr[length] = arr[rand];
      arr[rand] = t;
    }
    return arr;
  };


var arr = _.range(100);
</script>

Setup

var lodash = window.lodash,
        knut3 = window.knut3,
        underscore = window.underscore;

Test runner

Ready to run.

Testing in
TestOps/sec
_.shuffle
_.shuffle(arr);
ready
lodash.shuffle
lodash.shuffle(arr);
ready
changed Underscrore.shuffle
megascore.shuffle(arr);
ready
_.shuffle2
megascore.shuffle2(arr);
ready

Revisions

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