to var or not to var

Benchmark created by MONTILLET Xavier on


Preparation HTML

<script>
  var o = {
    p: 1
  };
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
to var
var i = 999,
    s = 0;
while (i--) {
  s += o.p;
}
if (s !== 999) {
  throw new Error('FAIL');
}
ready
not to var
var i = 999,
    s = 0,
    p;
while (i--) {
  p = o.p;
  s += p;
}
if (s !== 999) {
  throw new Error('FAIL');
}
ready

Revisions

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

  • Revision 1: published by MONTILLET Xavier on