var vs function

JavaScript performance comparison

Test case created by Prabakaran Sekar

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var a = {a:1,b:2,c:3};
  var b = function(){
  return {a:1,b:2,c:3}
  }

};
</script>

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
var
let result = 0
for(let i=0;i<100000;i++){
 result+= a.a;
}
pending…
func
let result = 0
for(let i=0;i<100000;i++){
 result+= b().a;
}
pending…

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

0 Comments