Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Switch vs Object Literal without function
(version: 0)
Comparing performance of:
Switch vs Object Literal
Created:
2 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
var str = 'abc'; str = str.charAt(Math.floor(Math.random() * 3));
Tests:
Switch
switch (str) { case 'a': console.log('A'); break; case 'b': console.log('B'); break; case 'c': console.log('C'); break; }
Object Literal
var objLiteral = { a: "adfasdfasdf", b: "sdfasdfasdf", c: "asdfasdf" } console.log(objLiteral[str]);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Switch
Object Literal
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Browser/OS:
Chrome 131 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Switch
496618.0 Ops/sec
Object Literal
456548.8 Ops/sec
Related benchmarks:
Switch vs Object Literal methods
Switch vs Object Literal - testing with stable input
Switch vs Object Literal (fixed prep code)
Switch vs Object Literal 24r34rf3rr
Switch vs Object Literal value return
Comments
Confirm delete:
Do you really want to delete benchmark?