Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Switch vs Object Literal version 2
(version: 0)
Comparing performance of:
Switch vs Object Literal
Created:
3 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
var str = 'abcdef'; str = str.charAt(Math.floor(Math.random() * 6));
Tests:
Switch
switch (str) { case 'a': console.log('A'); break; case 'b': console.log('B'); break; case 'c': console.log('C'); break; case 'd': console.log('D'); break; case 'e': console.log('E'); break; case 'f': console.log('F'); break; }
Object Literal
var objLiteral = { a: function() { console.log('A'); }, b: function() { console.log('B'); }, c: function() { console.log('C'); }, d: function() { console.log('D'); }, e: function() { console.log('E'); }, f: function() { console.log('F'); } } 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:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Related benchmarks:
Switch vs Object Literal - SR Test
Switch vs Object Literal methods
Switch vs Object Literal - testing with stable input
Switch vs Object Literal 24r34rf3rr
Switch vs Object Literal extended
Comments
Confirm delete:
Do you really want to delete benchmark?