Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Custom Build Query
(version: 1)
Comparing performance of:
URLSearchParams vs Custom vs Custom 2
Created:
one year ago
by:
Guest
Jump to the latest result
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)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
URLSearchParams
Custom
Custom 2
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
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/OS:
Safari 18 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
URLSearchParams
1505655.4 Ops/sec
Custom
1594484.5 Ops/sec
Custom 2
6042339.5 Ops/sec
Related benchmarks:
12121212212
URLSearchParams vs Custom
Map lookup or in operator
joined map or concatenate 3
aaa params str to obj
set.has vs string equals
test123kjfhneurkgewrxfiewhlrugxerg123
Custom Build Query 2
Custom Build Query 3
Comments
Confirm delete:
Do you really want to delete benchmark?