Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Custom Build Query
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.1 Safari/605.1.15
Browser:
Safari 18
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
URLSearchParams
1505655.4 Ops/sec
Custom
1594484.5 Ops/sec
Custom 2
6042339.5 Ops/sec
Script Preparation code:
var querystring = 'foo=bar&baz=qux&quxx=corge&grault=garply&waldo=fred&plugh=xyzzy' var queryobj = { foo: 'bar', baz: 'qux', quux: 'corge', grault: 'garply', waldo: 'fred', plugh: 'xyzzy' } function encode(data) { let result = '?' for (const key in data) { if (data[key] != null) { result += key + '=' + data[key] + '&' } } return result.slice(0, -1) } function encodeNative(data) { return new URLSearchParams(data).toString() } function buildQueryString(params) { const query = Object.entries(params) .filter(([_, value]) => value !== undefined && value !== null) .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`) .join('&'); return query ? `?${query}` : ''; }
Tests:
URLSearchParams
encodeNative(queryobj)
Custom
buildQueryString(queryobj)
Custom 2
encode(queryobj)