HTML Preparation code:
x
 
1
<script type='module'>
2
    import qs from 'https://cdn.skypack.dev/query-string';
3
4
    window.qs = qs
5
</script>
Script Preparation code:
 
window.string = 'hola=mundo&soy=david'
window.parseQuery = (query) => {
    const searchParams = new URLSearchParams(query);
    const result = {}
    for (const key in searchParams.keys()) {
        const items = searchParams.getAll(key)
        result[key] = items.length - 1 ? items : items[0]
    }
    return searchParams;
};
Tests:
  • query-string

     
    qs.parse(string)
  • URLSearchParams

     
    parseQuery(string)
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    query-string
    URLSearchParams

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 3 years ago)
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36
Chrome 96 on Linux
View result in a separate tab
Test name Executions per second
query-string 112308.4 Ops/sec
URLSearchParams 107696.7 Ops/sec