Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
Switch vs Object Lookup
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:152.0) Gecko/20100101 Firefox/152.0
Browser:
Firefox 152
Operating system:
Linux
Device Platform:
Desktop
Date tested:
2 months ago
Benchmark engine:
Benchmark.js
Object Literal
2298.8M/s
Switch
1646.7M/s
View exact numbers
Test name
Executions per second
✓
Object Literal
2,298,839,808 Ops/sec
Switch
1,646,745,472 Ops/sec
Script Preparation code:
var str = 'abc'; str = str.charAt(Math.floor(Math.random() * 3));
Tests:
Switch
switch (str) { case 'a': return 'A'; case 'b': return 'B'; case 'c': return 'C'; }
Object Literal
var objLiteral = { a: 'A', b: 'B', c: 'C' } objLiteral[str];