Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
pick by substring key
(version: 0)
Comparing performance of:
substring & array result vs string builder & array result vs substring & string result vs string builder & string result
Created:
2 years ago
by:
Guest
Jump to the latest result
Tests:
substring & array result
const object = {'key1': 'value1', 'key2': 'value2', 'key1 variant': 'value1 variant'} const result = [] const key='key1 variant' for (let i = 0; i <= key?.length; i++) { if (key[i] === ' ' || i === key.length) { const current = key.substring(0, i) if (object[current]) { result.push(object[current]) } } } const final = result.join(' ')
string builder & array result
const object = {'key1': 'value1', 'key2': 'value2', 'key1 variant': 'value1 variant'} const result = [] const key='key1 variant' let current = '' for (let i = 0; i <= key?.length; i++) { current += key[i] if (key[i] === ' ' || i === key.length) { if (object[current]) { result.push(object[current]) } } } const final = result.join(' ')
substring & string result
const object = {'key1': 'value1', 'key2': 'value2', 'key1 variant': 'value1 variant'} const result = '' const key='key1 variant' for (let i = 0; i <= key?.length; i++) { if (key[i] === ' ' || i === key.length) { const current = key.substring(0, i) if (object[current]) { result += ' ' + object[current] } } }
string builder & string result
const object = {'key1': 'value1', 'key2': 'value2', 'key1 variant': 'value1 variant'} const result = '' const key='key1 variant' let current = '' for (let i = 0; i <= key?.length; i++) { current += key[i] if (key[i] === ' ' || i === key.length) { if (object[current]) { result += ' ' + object[current] } } }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
substring & array result
string builder & array result
substring & string result
string builder & string result
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!
Comments
Confirm delete:
Do you really want to delete benchmark?