transducers-compare

JavaScript performance comparison

Revision 9 of this test case created by jdalton

Preparation code

<script src="https://cdn.rawgit.com/jlongster/transducers.js/eff56189887dee7284adca369dae90351de6d186/dist/transducers.js"></script>
<script>
var t1 = transducers;
</script>
<script src="https://cdn.rawgit.com/jdalton/aedf3009226f0d16e6c3/raw/63abde63b441febc13a6f24e91e0e9d29a2ae928/transducers-3arg.js"></script>
<script>
var t2 = transducers;
</script>
<script src="https://cdn.rawgit.com/lodash/lodash/1bd2c36d644d047f1058f8ac1f881be228f9b519/dist/lodash.js"></script>
<script>
var lodash1 = _.noConflict();
</script>
<script src="https://cdn.rawgit.com/jdalton/5f2676ade3188742a4fd/raw/ca8ffbd7df8fef5e496a0d85883a9a0e1f0d8335/lodash-1arg.js"></script>
<script>
var lodash2 = _.noConflict();
</script>
      
<script>
Benchmark.prototype.setup = function() {
  var reDigits = /^\d+/;
  var arr = lodash1.times(10000, String);
  
  function addPatch(x) { return x + '.1'; }
  function addTail(x) { return x + '.0-pre'; }
  function even(x) { return Number(reDigits.exec(x)) % 2 === 0; }
  function multipleOfFive(x) { return Number(reDigits.exec(x)) % 5 === 0; }

};
</script>

Preparation code output

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
transducers (3 args)
var r = t2
  .into([], t2.compose(
    t2.map(addPatch),
    t2.map(addTail),
    t2.filter(multipleOfFive),
    t2.filter(even)
  ), arr);
pending…
transducers (1 arg)
var r = t1
  .into([], t1.compose(
    t1.map(addPatch),
    t1.map(addTail),
    t1.filter(multipleOfFive),
    t1.filter(even)
  ), arr);
pending…
lodash (3 args)
var r = lodash1(arr)
  .map(addPatch)
  .map(addTail)
  .filter(multipleOfFive)
  .filter(even)
  .value();
pending…
lodash (1 arg)
var r = lodash2(arr)
  .map(addPatch)
  .map(addTail)
  .filter(multipleOfFive)
  .filter(even)
  .value();
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.

0 Comments