Do brackets make any difference?

JavaScript performance comparison

Test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var x = 0;
};
</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
No brackets (TRUE)
if (x == 0) y = 1;
pending…
With brackets (TRUE)
if (x == 0) {
  y = 1;
}
pending…
No brackets w/ else (TRUE)
if (x == 0) y = 1;
else y = 0;
pending…
With brackets w/ else (TRUE)
if (x == 0) {
  y = 1;
} else {
  y = 0;
}
pending…
No brackets (FALSE)
if (x == 1) y = 1;
pending…
With brackets (FALSE)
if (x == 1) {
  y = 1;
}
pending…
No brackets w/ else (FALSE)
if (x == 1) y = 1;
else y = 0;
pending…
With brackets w/ else (FALSE)
if (x == 1) {
  y = 1;
} else {
  y = 0;
}
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