If vs. Switch (v2)

Revision 2 of this benchmark created on


Description

Comparing a if vs. a switch statement

Preparation HTML

<script type="text/javascript">
    var j = 230;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Switch
switch(j) {
    case 34: void(0); break;
    case 'hello': void(0); break;
    case null: void(0); break;
    default: void(0);
}
ready
If
if(j == 34) void(0);
else if(j == 'hello') void(0); 
else if(j == null) void(0);
else void(0);
ready

Revisions

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

  • Revision 1: published by athlon32 on
  • Revision 2: published on
  • Revision 4: published by Christopher Hall on