function vs. no function

JavaScript performance comparison

Revision 2 of this test case created

Info

I Wanted to check, how bad the performance of a function is compared to using no function

Preparation code

<script>
  function inv(i) {
    if (i == 0) {
      return 1;
    } else {
      return 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
Function
a = 1;
a = inv(a);

a = 0;
a = inv(a);
pending…
No Function
a = 1;
if (a == 0) {
  a = 1;
} else {
  a = 0;
}

a = 0;
if (a == 0) {
  a = 1;
} else {
  a = 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