swith / if

JavaScript performance comparison

Test case created

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
switch
var type = 'angle', value = 90;

switch (type) {
case 'damage':
return -value;
case 'angle':
return value / 180 * Math.PI;
}
pending…
if
var type = 'angle', value = 90;

if (type === 'damage') {
return -damage;
} else if (type === 'angle') {
return value / 180 * Math.PI;
}
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