Script Preparation code:
AخA
 
var query = 'test=1&test=2&alt=test&b=8&c=9&alt=9';
Tests:
  • Object.entries with URLSearchParams

     
    var result = Object.fromEntries(new URLSearchParams(query));
  • map reduce

     
    var result = query.split('&')
            .map(p => p.split('='))
            .reduce((obj, pair) => {
              const [key, value] = pair.map(decodeURIComponent);
              obj[key] = value;
              return obj;
            }, {});
  • json parse decodeURI

     
    var result = JSON.parse('{"' + decodeURI(query).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g,'":"') + '"}')
  • json parse decodeURIComponent

     
    var result = JSON.parse('{"' + query.replace(/&/g, '","').replace(/=/g,'":"') + '"}', function(key, value) { return key===""?value:decodeURIComponent(value) })
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Object.entries with URLSearchParams
    map reduce
    json parse decodeURI
    json parse decodeURIComponent

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 16 days ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36
Chrome 133 on Mac OS X 10.15.7
View result in a separate tab
Test name Executions per second
Object.entries with URLSearchParams 481354.2 Ops/sec
map reduce 1289953.6 Ops/sec
json parse decodeURI 1187845.0 Ops/sec
json parse decodeURIComponent 640233.2 Ops/sec