Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
pick by substring key fixed
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36
Browser:
Chrome 123
Operating system:
Linux
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
substring & array result
4887203.5 Ops/sec
string builder & array result
3651537.8 Ops/sec
substring & string result
7416484.0 Ops/sec
string builder & string result
3815308.0 Ops/sec
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'} let 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'} let 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] } } }