htns case

JavaScript performance comparison

Revision 2 of this test case created

Preparation code

<script>
function A2(fun,a,b) {
  return fun.arity === 2 ? fun.func(a,b) : fun(a)(b);
}
function A3(fun,a,b,c) {
  return fun.arity === 3 ? fun.func(a,b,c) : fun(a)(b)(c);
}
function F2(fun) {
  function wrapper(a) { return function(b) { return fun(a,b) } }
  wrapper.arity = 2;
  wrapper.func = fun;
  return wrapper;
}

function F3(fun) {
  function wrapper(a) {
    return function(b) { return function(c) { return fun(a,b,c) }}
  }
  wrapper.arity = 3;
  wrapper.func = fun;
  return wrapper;
}

  var e, case0, zipWith_0;
  zipWith_0 = F3(function(f_1, listX_2, listY_3) {
    return (case0 = {
      ctor: "Tuple2",
      _0: listX_2,
      _1: listY_3
    }, (e = case0.ctor === 'Tuple2' ? (e = case0._0.ctor === 'Cons' ? (e = case0._1.ctor === 'Cons' ? {
      ctor: 'Cons',
      _0: A2(f_1, case0._0._0, case0._1._0),
      _1: A3(zipWith_0, f_1, case0._0._1, case0._1._1)
    } : null, e !== null ? e : null) : null, e !== null ? e : {
      ctor: "Nil"
    }) : null, e !== null ? e : Elm.Error.Case('Line 17, Column 3')));
  });

  f_1 = F2(function(x_9, y_10){return x_9+y_10});

  var Nil = { ctor:'Nil' };
  function Cons(hd,tl) { return { ctor:"Cons", _0:hd, _1:tl }; }
  function range(lo,hi) {
    var lst = Nil;
    if (lo <= hi) {
        do { lst = Cons(hi,lst) } while (hi-->lo);
    }
    return lst
  }

  var list = range(0,1000);

function zip_0(f_3){
  return function(listX_4){
   return function(listY_5){
    return function(){
    var case0=['Tuple2',listX_4,listY_5];
    switch(case0[0]){
     case 'Tuple2':
     switch(case0[1][0]){
      case 'Cons':
      switch(case0[2][0]){
       case 'Cons':
       return ['Cons',f_3(case0[1][1])(case0[2][1]),zip_0(f_3)(case0[1][2])(case0[2][2])];
      }break;
     }break;
    }
    return ['Nil'];}();};};}
 function f_2(x_10){
  return function(y_11){
   return (x_10+y_11);};}
 var list_2=function(){
  var lo=0;
  var hi=999;
  var lst=["Nil"];if(lo<=hi){do{lst=['Cons',hi,lst]}while(hi-->lo)}
  return lst;}();

  var e, case0, zipWith_1;
  zipWith_1 = F3(function(f_1, listX_2, listY_3) {
    return (case0 = {
      ctor: "Tuple2",
      _0: listX_2,
      _1: listY_3
    }, (e = case0.ctor === 'Tuple2' ? (e = case0._0.ctor === 'Cons' ? (e = case0._1.ctor === 'Cons' ? {
      ctor: 'Cons',
      _0: f_2(case0._0._0)(case0._1._0),
      _1: zipWith_1(f_1)(case0._0._1)(case0._1._1)
    } : null, e !== null ? e : null) : null, e !== null ? e : {
      ctor: "Nil"
    }) : null, e !== null ? e : Elm.Error.Case('Line 17, Column 3')));
  });

</script>

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
old
zip_0(f_2)(list_2)(list_2)
pending…
new
A3(zipWith_0, f_1, list, list)
pending…
half new
zipWith_1(f_2)(list)(list)
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