yet-another-stupid-benchmark

Benchmark created by L8D on


Preparation HTML

<script>
var toArray = Function.call.bind([].slice);

function fancy() {
  return toArray(arguments);
}

function unfancy() {
  return Array.prototype.slice.call(arguments, 0);
}

function theHardWay() {
  var index = arguments.length;
  var res = new Array(index);
  while (index--) res[index] = arguments[index];
  return res;
}

function lessHardButStillHardWay() {
  var index = 0;
  var res = [];

  while (index < arguments.length) res.push(arguments[index++]);
  return res;
}
</script>

Teardown


    if (res[0] !== 1 || res[1] !== 2 || res[2] !== 3 || res.length !== 3) throw new Error();
  

Test runner

Ready to run.

Testing in
TestOps/sec
fancy
var res = fancy(1, 2, 3);
ready
unfancy
var res = unfancy(1, 2, 3);
ready
theHardWay
var res = theHardWay(1, 2, 3);
ready
lessHardButStillHardWay
var res = lessHardButStillHardWay(1, 2, 3);
ready

Revisions

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