Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
string vs numeric enum values compare - v2
(version: 1)
Comparing performance of:
string enums vs numeric enums vs string enums with CONST
Created:
one year ago
by:
Guest
Jump to the latest result
Tests:
string enums
const a = { one: 'longLiteralTest', two: 'longLiteralTesT', }; let c = 0; for (let i = 0; i < 100000; i++) { const v = i % 2 === 0 ? a.one : a.two; if (v === 'longLiteralTest') { c++; } }
numeric enums
const a = { one: 1, two: 2, }; let c = 0; for (let i = 0; i < 100000; i++) { const v = i % 2 === 0 ? a.one : a.two; if (v === a.one) { c++; } }
string enums with CONST
const aOne = 'longLiteralTest' const aTwo = 'longLiteralTesT' const a = { one: 'longLiteralTest', two: 'longLiteralTesT', }; let c = 0; for (let i = 0; i < 100000; i++) { const v = i % 2 === 0 ? a.one : a.two; if (v === aOne) { c++; } }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
string enums
numeric enums
string enums with CONST
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one month ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36 Edg/146.0.0.0
Browser/OS:
Chrome 146 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
string enums
14002.4 Ops/sec
numeric enums
14067.4 Ops/sec
string enums with CONST
17773.7 Ops/sec
Related benchmarks:
sdfasfasdfabc
more vs not equal
Comparing int to string using loose equality
return the bigger value of two variables
Comparison Check (number VS string)
array.indexof vs for
sdjfkpweiufjq
string vs numeric enum values compare
string vs numeric enum values compare -
Comments
Confirm delete:
Do you really want to delete benchmark?