Single pass vs multiple passes

JavaScript performance comparison

Test case created by Brian


This is the simple array fusion example from Rephrase:

Preparation code

Benchmark.prototype.setup = function() {
    var array = [];
    var add1 = add(1);
    var add2 = add(2);
    function add(a) {
      return function(b) {
        return a + b;
    (function() {
      var size = 100000;
      var i;
      for (i = 0; i < size; i++) {

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Multiple pass;
Single pass {
  return add1(add2(x));

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

Compare results of other browsers

1 comment

Hayk Saakian commented :


This data seems too close to call, I wish more people ran this jsperf.

Comment form temporarily disabled.

Add a comment