Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
condition if-else switch map
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0
Browser:
Chrome 120
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
switch
1136350720.0 Ops/sec
if-else
1115009536.0 Ops/sec
map
3435309.2 Ops/sec
Tests:
switch
function test(a) { switch(a) { case 0: return 0; case 1: return 0; case 2: return 0; case 3: return 0; case 4: return 0; case 5: return 0; case 6: return 0; case 7: return 0; case 8: return 0; case 9: return 0; case 10: return 0; case 11: return 0; case 12: return 0; default: return 0; } } test(12)
if-else
function test(a) { if (a === 0) { return 0; } else if (a === 1) { return 0; } else if (a === 2) { return 0; } else if (a === 3) { return 0; } else if (a === 4) { return 0; } else if (a === 5) { return 0; } else if (a === 6) { return 0; } else if (a === 7) { return 0; } else if (a === 8) { return 0; } else if (a === 9) { return 0; } else if (a === 10) { return 0; } else if (a === 11) { return 0; } else if (a === 12) { return 0; } else { return 0; } } test(12)
map
function test(a) { const map = new Map([ [0,0], [1,0], [2,0], [3,0], [4,0], [5,0], [6,0], [7,0], [8,0], [9,0], [10,0], [11,0], [12,0], ]) return map.get(a) || 0 } test(12)