Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

benchmark: URLSearchParams v.s. querystring #11170

Closed
wants to merge 3 commits into from

Conversation

joyeecheung
Copy link
Member

@joyeecheung joyeecheung commented Feb 4, 2017

This PR is a follow-up of #10678, which compare the performance of URLSearchParams to querystring counterparts.

Also it fixes a mistake in legacy-vs-whatwg-url-parse.js where the first call to new URL was written as url.parse .

Refs: #10874 (comment)

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

benchmark, url

@nodejs-github-bot nodejs-github-bot added the benchmark Issues and PRs related to the benchmark subsystem. label Feb 4, 2017
@joyeecheung
Copy link
Member Author

Benchmark results
"filename", "configuration", "rate", "time"
"url/legacy-vs-whatwg-url-searchparams-parse.js", "n=100000 method=""legacy"" type=""noencode""", 701665.7988113234, 0.142517991
"url/legacy-vs-whatwg-url-searchparams-parse.js", "n=100000 method=""whatwg"" type=""noencode""", 552666.4181657383, 0.180940974
"url/legacy-vs-whatwg-url-searchparams-parse.js", "n=100000 method=""legacy"" type=""encodemany""", 329444.5913401272, 0.30354118
"url/legacy-vs-whatwg-url-searchparams-parse.js", "n=100000 method=""whatwg"" type=""encodemany""", 303372.93978298944, 0.32962729
"url/legacy-vs-whatwg-url-searchparams-parse.js", "n=100000 method=""legacy"" type=""encodelast""", 588217.7271682303, 0.170005077
"url/legacy-vs-whatwg-url-searchparams-parse.js", "n=100000 method=""whatwg"" type=""encodelast""", 387422.55156841147, 0.258116105
"url/legacy-vs-whatwg-url-searchparams-parse.js", "n=100000 method=""legacy"" type=""multivalue""", 585475.1473030588, 0.170801443
"url/legacy-vs-whatwg-url-searchparams-parse.js", "n=100000 method=""whatwg"" type=""multivalue""", 450455.16196795536, 0.221997678
"url/legacy-vs-whatwg-url-searchparams-parse.js", "n=100000 method=""legacy"" type=""multivaluemany""", 234961.99196077543, 0.42560075
"url/legacy-vs-whatwg-url-searchparams-parse.js", "n=100000 method=""whatwg"" type=""multivaluemany""", 207464.48245403994, 0.482010216
"url/legacy-vs-whatwg-url-searchparams-parse.js", "n=100000 method=""legacy"" type=""manypairs""", 101698.05382854801, 0.983302986
"url/legacy-vs-whatwg-url-searchparams-parse.js", "n=100000 method=""whatwg"" type=""manypairs""", 82709.3160806023, 1.209053644
"url/legacy-vs-whatwg-url-searchparams-serialize.js", "n=100000 method=""legacy"" type=""noencode""", 2087508.0885719662, 0.047904006
"url/legacy-vs-whatwg-url-searchparams-serialize.js", "n=100000 method=""whatwg"" type=""noencode""", 957945.566946433, 0.104390065
"url/legacy-vs-whatwg-url-searchparams-serialize.js", "n=100000 method=""legacy"" type=""encodemany""", 2006553.4839406896, 0.049836698
"url/legacy-vs-whatwg-url-searchparams-serialize.js", "n=100000 method=""whatwg"" type=""encodemany""", 955673.9682324034, 0.104638196
"url/legacy-vs-whatwg-url-searchparams-serialize.js", "n=100000 method=""legacy"" type=""encodelast""", 1871094.8496336725, 0.053444645
"url/legacy-vs-whatwg-url-searchparams-serialize.js", "n=100000 method=""whatwg"" type=""encodelast""", 1046005.1145256879, 0.095601827
"url/legacy-vs-whatwg-url-searchparams-serialize.js", "n=100000 method=""legacy"" type=""multivalue""", 1805964.6316274612, 0.05537207
"url/legacy-vs-whatwg-url-searchparams-serialize.js", "n=100000 method=""whatwg"" type=""multivalue""", 1024147.262216766, 0.097642208
"url/legacy-vs-whatwg-url-searchparams-serialize.js", "n=100000 method=""legacy"" type=""multivaluemany""", 984058.1206768975, 0.101620014
"url/legacy-vs-whatwg-url-searchparams-serialize.js", "n=100000 method=""whatwg"" type=""multivaluemany""", 587170.9155831832, 0.170308163
"url/legacy-vs-whatwg-url-searchparams-serialize.js", "n=100000 method=""legacy"" type=""manypairs""", 327120.6759917366, 0.305697583
"url/legacy-vs-whatwg-url-searchparams-serialize.js", "n=100000 method=""whatwg"" type=""manypairs""", 133856.77722659096, 0.747067142

@joyeecheung joyeecheung added querystring Issues and PRs related to the built-in querystring module. whatwg-url Issues and PRs related to the WHATWG URL implementation. labels Feb 4, 2017
@TimothyGu
Copy link
Member

After this, it seems url-searchparams-stringifier.js and url-searchparams-parse.js are unneeded and should be removed, since their features can be reproduced with method=legacy.

The first commit LGTM.


const inputs = {
noencode: 'foo=bar&baz=quux&xyzzy=thud',
encodemany: '%66%6F%6F=bar&%62%61%7A=quux&xyzzy=%74h%75d',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason why you didn't include multicharsep and encodefake in the benchmark?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

URLSearchParams doesn't support custom separators, so multicharsep is not needed.

I copied the input from url-searchparams-* benchmarks, looks like there isn't encodefake in them.

Copy link
Member

@TimothyGu TimothyGu Feb 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, but I think it's beneficial to have a benchmark case with duplicated & à la #10454, even w/o custom separators.

Add benchmarks to compare the performance between
URLSearchParams and querystring, remove duplicate
benchmarks.
@joyeecheung
Copy link
Member Author

@TimothyGu Thanks for the review, I've deleted url-searchparams-stringifier.js and url-searchparams-parse.js and added encodefake, PTAL

@joyeecheung
Copy link
Member Author

New benchmark results
"filename", "configuration", "rate", "time"
"url/legacy-vs-whatwg-url-searchparams-parse.js", "n=100000 method=""legacy"" type=""noencode""", 734274.1892019577, 0.136188908
"url/legacy-vs-whatwg-url-searchparams-parse.js", "n=100000 method=""whatwg"" type=""noencode""", 554793.1557187826, 0.180247357
"url/legacy-vs-whatwg-url-searchparams-parse.js", "n=100000 method=""legacy"" type=""encodemany""", 281883.5375670236, 0.354756439
"url/legacy-vs-whatwg-url-searchparams-parse.js", "n=100000 method=""whatwg"" type=""encodemany""", 262448.4441027436, 0.381027216
"url/legacy-vs-whatwg-url-searchparams-parse.js", "n=100000 method=""legacy"" type=""encodefake""", 643062.0908794767, 0.155505979
"url/legacy-vs-whatwg-url-searchparams-parse.js", "n=100000 method=""whatwg"" type=""encodefake""", 483293.1619251652, 0.206913749
"url/legacy-vs-whatwg-url-searchparams-parse.js", "n=100000 method=""legacy"" type=""encodelast""", 510367.36273391626, 0.195937294
"url/legacy-vs-whatwg-url-searchparams-parse.js", "n=100000 method=""whatwg"" type=""encodelast""", 437500.5772273241, 0.228571127
"url/legacy-vs-whatwg-url-searchparams-parse.js", "n=100000 method=""legacy"" type=""multivalue""", 541015.4234083545, 0.184837614
"url/legacy-vs-whatwg-url-searchparams-parse.js", "n=100000 method=""whatwg"" type=""multivalue""", 437601.50823385746, 0.228518408
"url/legacy-vs-whatwg-url-searchparams-parse.js", "n=100000 method=""legacy"" type=""multivaluemany""", 250108.5908974529, 0.39982633
"url/legacy-vs-whatwg-url-searchparams-parse.js", "n=100000 method=""whatwg"" type=""multivaluemany""", 199566.1097502964, 0.501087084
"url/legacy-vs-whatwg-url-searchparams-parse.js", "n=100000 method=""legacy"" type=""manypairs""", 107447.1215269644, 0.930690358
"url/legacy-vs-whatwg-url-searchparams-parse.js", "n=100000 method=""whatwg"" type=""manypairs""", 85509.30339852828, 1.169463392
"url/legacy-vs-whatwg-url-searchparams-serialize.js", "n=100000 method=""legacy"" type=""noencode""", 2154038.526056058, 0.046424425
"url/legacy-vs-whatwg-url-searchparams-serialize.js", "n=100000 method=""whatwg"" type=""noencode""", 991281.4418117199, 0.100879524
"url/legacy-vs-whatwg-url-searchparams-serialize.js", "n=100000 method=""legacy"" type=""encodemany""", 2134596.604680756, 0.046847259
"url/legacy-vs-whatwg-url-searchparams-serialize.js", "n=100000 method=""whatwg"" type=""encodemany""", 972833.6211299463, 0.1027925
"url/legacy-vs-whatwg-url-searchparams-serialize.js", "n=100000 method=""legacy"" type=""encodefake""", 1205527.6335263504, 0.08295123
"url/legacy-vs-whatwg-url-searchparams-serialize.js", "n=100000 method=""whatwg"" type=""encodefake""", 780084.1703018913, 0.128191295
"url/legacy-vs-whatwg-url-searchparams-serialize.js", "n=100000 method=""legacy"" type=""encodelast""", 1735685.898199488, 0.057614111
"url/legacy-vs-whatwg-url-searchparams-serialize.js", "n=100000 method=""whatwg"" type=""encodelast""", 988627.9119911569, 0.10115029
"url/legacy-vs-whatwg-url-searchparams-serialize.js", "n=100000 method=""legacy"" type=""multivalue""", 2106025.583493342, 0.047482804
"url/legacy-vs-whatwg-url-searchparams-serialize.js", "n=100000 method=""whatwg"" type=""multivalue""", 980357.4022317012, 0.102003616
"url/legacy-vs-whatwg-url-searchparams-serialize.js", "n=100000 method=""legacy"" type=""multivaluemany""", 1081755.7575287307, 0.092442309
"url/legacy-vs-whatwg-url-searchparams-serialize.js", "n=100000 method=""whatwg"" type=""multivaluemany""", 610422.7909113565, 0.163820882
"url/legacy-vs-whatwg-url-searchparams-serialize.js", "n=100000 method=""legacy"" type=""manypairs""", 321331.6538998709, 0.311204946
"url/legacy-vs-whatwg-url-searchparams-serialize.js", "n=100000 method=""whatwg"" type=""manypairs""", 124584.44996870444, 0.802668391

@joyeecheung
Copy link
Member Author

@TimothyGu Does this LGTY?

@TimothyGu
Copy link
Member

TimothyGu commented Feb 7, 2017

@joyeecheung, I still prefer to have a test case with a disproportionately large number of & (see #11170 (comment)).

@joyeecheung
Copy link
Member Author

@TimothyGu New cases added, PTAL. Personally I don't find the performance impact on an edge case like this significant though.

@joyeecheung
Copy link
Member Author

joyeecheung commented Feb 8, 2017

New numbers

url/legacy-vs-whatwg-url-searchparams-parse.js
url/legacy-vs-whatwg-url-searchparams-parse.js n=100000 method="legacy" type="noencode": 728,117.6614841192
url/legacy-vs-whatwg-url-searchparams-parse.js n=100000 method="whatwg" type="noencode": 562,869.8491132808
url/legacy-vs-whatwg-url-searchparams-parse.js n=100000 method="legacy" type="encodemany": 284,702.0308971683
url/legacy-vs-whatwg-url-searchparams-parse.js n=100000 method="whatwg" type="encodemany": 266,461.49841852434
url/legacy-vs-whatwg-url-searchparams-parse.js n=100000 method="legacy" type="encodefake": 659,708.3662849416
url/legacy-vs-whatwg-url-searchparams-parse.js n=100000 method="whatwg" type="encodefake": 542,555.6214459216
url/legacy-vs-whatwg-url-searchparams-parse.js n=100000 method="legacy" type="encodelast": 531,983.3525172737
url/legacy-vs-whatwg-url-searchparams-parse.js n=100000 method="whatwg" type="encodelast": 407,554.168116184
url/legacy-vs-whatwg-url-searchparams-parse.js n=100000 method="legacy" type="multicharsep": 558,516.3157053464
url/legacy-vs-whatwg-url-searchparams-parse.js n=100000 method="whatwg" type="multicharsep": 419,433.3451312943
url/legacy-vs-whatwg-url-searchparams-parse.js n=100000 method="legacy" type="multivalue": 540,090.531271069
url/legacy-vs-whatwg-url-searchparams-parse.js n=100000 method="whatwg" type="multivalue": 410,658.8087158373
url/legacy-vs-whatwg-url-searchparams-parse.js n=100000 method="legacy" type="multivaluemany": 234,362.9390972467
url/legacy-vs-whatwg-url-searchparams-parse.js n=100000 method="whatwg" type="multivaluemany": 190,289.91296196467
url/legacy-vs-whatwg-url-searchparams-parse.js n=100000 method="legacy" type="manypairs": 103,794.97803962423
url/legacy-vs-whatwg-url-searchparams-parse.js n=100000 method="whatwg" type="manypairs": 83,176.5809668853

url/legacy-vs-whatwg-url-searchparams-serialize.js
url/legacy-vs-whatwg-url-searchparams-serialize.js n=100000 method="legacy" type="noencode": 2,023,561.5002126459
url/legacy-vs-whatwg-url-searchparams-serialize.js n=100000 method="whatwg" type="noencode": 963,139.3380325993
url/legacy-vs-whatwg-url-searchparams-serialize.js n=100000 method="legacy" type="encodemany": 1,838,149.8404237789
url/legacy-vs-whatwg-url-searchparams-serialize.js n=100000 method="whatwg" type="encodemany": 1,035,415.8503922668
url/legacy-vs-whatwg-url-searchparams-serialize.js n=100000 method="legacy" type="encodefake": 1,266,424.7533659954
url/legacy-vs-whatwg-url-searchparams-serialize.js n=100000 method="whatwg" type="encodefake": 746,707.4866759384
url/legacy-vs-whatwg-url-searchparams-serialize.js n=100000 method="legacy" type="encodelast": 1,827,252.866196869
url/legacy-vs-whatwg-url-searchparams-serialize.js n=100000 method="whatwg" type="encodelast": 957,136.6361649234
url/legacy-vs-whatwg-url-searchparams-serialize.js n=100000 method="legacy" type="multicharsep": 1,789,293.447739802
url/legacy-vs-whatwg-url-searchparams-serialize.js n=100000 method="whatwg" type="multicharsep": 851,305.8687247362
url/legacy-vs-whatwg-url-searchparams-serialize.js n=100000 method="legacy" type="multivalue": 2,123,182.4602707974
url/legacy-vs-whatwg-url-searchparams-serialize.js n=100000 method="whatwg" type="multivalue": 1,041,201.8025993624
url/legacy-vs-whatwg-url-searchparams-serialize.js n=100000 method="legacy" type="multivaluemany": 990,080.7473224528
url/legacy-vs-whatwg-url-searchparams-serialize.js n=100000 method="whatwg" type="multivaluemany": 641,498.9644570892
url/legacy-vs-whatwg-url-searchparams-serialize.js n=100000 method="legacy" type="manypairs": 324,359.9572819234
url/legacy-vs-whatwg-url-searchparams-serialize.js n=100000 method="whatwg" type="manypairs": 120,641.53559032189

@joyeecheung
Copy link
Member Author

Copy link
Member

@TimothyGu TimothyGu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. You might find the cases in #11234 interesting, though I'm just fine with landing this as-is.

@joyeecheung
Copy link
Member Author

@TimothyGu I'm planning on unifying the inputs to url-related benchmarks a bit after this. Thanks for the heads up though :)

@joyeecheung
Copy link
Member Author

Landed in c6b586d and ab3e086, thanks for the review!

@joyeecheung joyeecheung closed this Feb 9, 2017
joyeecheung added a commit that referenced this pull request Feb 9, 2017
PR-URL: #11170
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
joyeecheung added a commit that referenced this pull request Feb 9, 2017
Add benchmarks to compare the performance between
URLSearchParams and querystring, remove duplicate
benchmarks.

PR-URL: #11170
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
italoacasas pushed a commit to italoacasas/node that referenced this pull request Feb 9, 2017
PR-URL: nodejs#11170
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
italoacasas pushed a commit to italoacasas/node that referenced this pull request Feb 9, 2017
Add benchmarks to compare the performance between
URLSearchParams and querystring, remove duplicate
benchmarks.

PR-URL: nodejs#11170
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
italoacasas pushed a commit to italoacasas/node that referenced this pull request Feb 14, 2017
PR-URL: nodejs#11170
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
italoacasas pushed a commit to italoacasas/node that referenced this pull request Feb 14, 2017
Add benchmarks to compare the performance between
URLSearchParams and querystring, remove duplicate
benchmarks.

PR-URL: nodejs#11170
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
@joyeecheung joyeecheung deleted the sp-benchmarks branch February 19, 2017 17:43
krydos pushed a commit to krydos/node that referenced this pull request Feb 25, 2017
PR-URL: nodejs#11170
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
krydos pushed a commit to krydos/node that referenced this pull request Feb 25, 2017
Add benchmarks to compare the performance between
URLSearchParams and querystring, remove duplicate
benchmarks.

PR-URL: nodejs#11170
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
benchmark Issues and PRs related to the benchmark subsystem. querystring Issues and PRs related to the built-in querystring module. whatwg-url Issues and PRs related to the WHATWG URL implementation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants