Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
parsing query param keys with string or regex
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36 Edg/146.0.0.0
Browser:
Chrome 146
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one month ago
Test name
Executions per second
string parser
7149721.0 Ops/sec
regex parser
1384794.6 Ops/sec
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
const params = { 'key[subKey1]': 'value1', 'key[subKey2]': 'value2', 'otherKey': 'otherValue', 'key2[subKey3]': 'value3', 'key2[subKey4]': 'value4', }; const key = 'key2';
Tests:
string parser
const value = {} for (const paramKey in params) { if (paramKey.startsWith(`${key}[`) && paramKey.endsWith(']')) { const subKey = paramKey.substring(key.length + 1, paramKey.length - 1); value[subKey] = params[paramKey]; } }
regex parser
const value = {} for (const paramKey in params) { // regex: const match = paramKey.match(new RegExp(`^${key}\\[(.+)\\]$`)) if (match) { value[match[1]] = params[paramKey]; } }