GitHub PullRequestEvent at 2014-12-31 02:36:47
Repository: node
Actor: mscdex
Payload: {"action":"opened","number":8958,"pull_request":{"url":"https://api.github.com/repos/joyent/node/pulls/8958","id":26713225,"html_url":"https://github.com/joyent/node/pull/8958","diff_url":"https://github.com/joyent/node/pull/8958.diff","patch_url":"https://github.com/joyent/node/pull/8958.patch","issue_url":"https://api.github.com/repos/joyent/node/issues/8958","number":8958,"state":"open","locked":false,"title":"querystring: improve parse() performance","user":{"login":"mscdex","id":54666,"avatar_url":"https://avatars.githubusercontent.com/u/54666?v=3","gravatar_id":"","url":"https://api.github.com/users/mscdex","html_url":"https://github.com/mscdex","followers_url":"https://api.github.com/users/mscdex/followers","following_url":"https://api.github.com/users/mscdex/following{/other_user}","gists_url":"https://api.github.com/users/mscdex/gists{/gist_id}","starred_url":"https://api.github.com/users/mscdex/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mscdex/subscriptions","organizations_url":"https://api.github.com/users/mscdex/orgs","repos_url":"https://api.github.com/users/mscdex/repos","events_url":"https://api.github.com/users/mscdex/events{/privacy}","received_events_url":"https://api.github.com/users/mscdex/received_events","type":"User","site_admin":false},"body":"The big differences in this improvment come from moving the try-catch out of `parse()` and from the new `indexOf()` check. The gains are significant on unencoded strings and speed impact for encoded strings is negligible.\r\n\r\nI have a version of this for the v0.10 branch where the gains on unencoded strings are slightly higher and the speed impact for encoded strings is about the same as on v0.12.\r\n\r\nOn v0.12 I get these kinds of results:\r\n\r\n```\r\nBenchmarking non-encoded data:\r\nquerystring#oldParse x 292,698 ops/sec ±0.11% (196 runs sampled)\r\nquerystring#newParse x 431,425 ops/sec ±0.15% (193 runs sampled)\r\nFastest is querystring#newParse\r\n\r\nBenchmarking encoded data:\r\nquerystring#oldParse x 246,595 ops/sec ±0.16% (196 runs sampled)\r\nquerystring#newParse x 287,151 ops/sec ±0.25% (196 runs sampled)\r\nFastest is querystring#newParse\r\n```\r\n\r\nOn v0.10 I get these kinds of results:\r\n\r\n```\r\nBenchmarking non-encoded data:\r\nquerystring#oldParse x 297,629 ops/sec ±0.19% (195 runs sampled)\r\nquerystring#newParse x 511,708 ops/sec ±0.08% (198 runs sampled)\r\nFastest is querystring#newParse\r\n\r\nBenchmarking encoded data:\r\nquerystring#oldParse x 252,407 ops/sec ±0.21% (197 runs sampled)\r\nquerystring#newParse x 279,290 ops/sec ±0.16% (195 runs sampled)\r\nFastest is querystring#newParse\r\n```\r\n\r\nHere is my benchmark code:\r\n\r\n```javascript\r\nvar Benchmark = require('benchmark');\r\nvar oldQSParse = require('querystring').parse,\r\n    newQSParse = require('./querystring').parse;\r\nvar QSTR = 'foo=bar&baz=quux&xyzzy=thud',\r\n    QSTR_ENC = '%66%6F%6F=bar&%62%61%7A=quux&xyzzy=%74h%75d';\r\n\r\nconsole.log('Benchmarking non-encoded data:');\r\nvar suite = new Benchmark.Suite();\r\nsuite.add('querystring#oldParse', function() {\r\n  var r = oldQSParse(QSTR);\r\n}, { minSamples: 100 });\r\nsuite.add('querystring#newParse', function() {\r\n  var r = newQSParse(QSTR);\r\n}, { minSamples: 100 });\r\nsuite.on('cycle', function(event) {\r\n  console.log(String(event.target));\r\n});\r\nsuite.on('complete', function() {\r\n  console.log('Fastest is ' + this.filter('fastest').pluck('name'));\r\n});\r\nsuite.run({ async: false });\r\n\r\nconsole.log('\\nBenchmarking encoded data:');\r\nsuite = new Benchmark.Suite();\r\nsuite.add('querystring#oldParse', function() {\r\n  var r = oldQSParse(QSTR_ENC);\r\n}, { minSamples: 100 });\r\nsuite.add('querystring#newParse', function() {\r\n  var r = newQSParse(QSTR_ENC);\r\n}, { minSamples: 100 });\r\nsuite.on('cycle', function(event) {\r\n  console.log(String(event.target));\r\n});\r\nsuite.on('complete', function() {\r\n  console.log('Fastest is ' + this.filter('fastest').pluck('name'));\r\n});\r\nsuite.run({ async: false });\r\n```\r\n","created_at":"2014-12-31T02:36:46Z","updated_at":"2014-12-31T02:36:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/joyent/node/pulls/8958/commits","review_comments_url":"https://api.github.com/repos/joyent/node/pulls/8958/comments","review_comment_url":"https://api.github.com/repos/joyent/node/pulls/comments/{number}","comments_url":"https://api.github.com/repos/joyent/node/issues/8958/comments","statuses_url":"https://api.github.com/repos/joyent/node/statuses/754dfd0ecdada5d4bc11c58e89950d2e5a45609e","head":{"label":"mscdex:qsparse-perf-012","ref":"qsparse-perf-012","sha":"754dfd0ecdada5d4bc11c58e89950d2e5a45609e","user":{"login":"mscdex","id":54666,"avatar_url":"https://avatars.githubusercontent.com/u/54666?v=3","gravatar_id":"","url":"https://api.github.com/users/mscdex","html_url":"https://github.com/mscdex","followers_url":"https://api.github.com/users/mscdex/followers","following_url":"https://api.github.com/users/mscdex/following{/other_user}","gists_url":"https://api.github.com/users/mscdex/gists{/gist_id}","starred_url":"https://api.github.com/users/mscdex/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mscdex/subscriptions","organizations_url":"https://api.github.com/users/mscdex/orgs","repos_url":"https://api.github.com/users/mscdex/repos","events_url":"https://api.github.com/users/mscdex/events{/privacy}","received_events_url":"https://api.github.com/users/mscdex/received_events","type":"User","site_admin":false},"repo":{"id":15457833,"name":"node","full_name":"mscdex/node","owner":{"login":"mscdex","id":54666,"avatar_url":"https://avatars.githubusercontent.com/u/54666?v=3","gravatar_id":"","url":"https://api.github.com/users/mscdex","html_url":"https://github.com/mscdex","followers_url":"https://api.github.com/users/mscdex/followers","following_url":"https://api.github.com/users/mscdex/following{/other_user}","gists_url":"https://api.github.com/users/mscdex/gists{/gist_id}","starred_url":"https://api.github.com/users/mscdex/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mscdex/subscriptions","organizations_url":"https://api.github.com/users/mscdex/orgs","repos_url":"https://api.github.com/users/mscdex/repos","events_url":"https://api.github.com/users/mscdex/events{/privacy}","received_events_url":"https://api.github.com/users/mscdex/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mscdex/node","description":"evented I/O for v8 javascript","fork":true,"url":"https://api.github.com/repos/mscdex/node","forks_url":"https://api.github.com/repos/mscdex/node/forks","keys_url":"https://api.github.com/repos/mscdex/node/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mscdex/node/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mscdex/node/teams","hooks_url":"https://api.github.com/repos/mscdex/node/hooks","issue_events_url":"https://api.github.com/repos/mscdex/node/issues/events{/number}","events_url":"https://api.github.com/repos/mscdex/node/events","assignees_url":"https://api.github.com/repos/mscdex/node/assignees{/user}","branches_url":"https://api.github.com/repos/mscdex/node/branches{/branch}","tags_url":"https://api.github.com/repos/mscdex/node/tags","blobs_url":"https://api.github.com/repos/mscdex/node/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mscdex/node/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mscdex/node/git/refs{/sha}","trees_url":"https://api.github.com/repos/mscdex/node/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mscdex/node/statuses/{sha}","languages_url":"https://api.github.com/repos/mscdex/node/languages","stargazers_url":"https://api.github.com/repos/mscdex/node/stargazers","contributors_url":"https://api.github.com/repos/mscdex/node/contributors","subscribers_url":"https://api.github.com/repos/mscdex/node/subscribers","subscription_url":"https://api.github.com/repos/mscdex/node/subscription","commits_url":"https://api.github.com/repos/mscdex/node/commits{/sha}","git_commits_url":"https://api.github.com/repos/mscdex/node/git/commits{/sha}","comments_url":"https://api.github.com/repos/mscdex/node/comments{/number}","issue_comment_url":"https://api.github.com/repos/mscdex/node/issues/comments/{number}","contents_url":"https://api.github.com/repos/mscdex/node/contents/{+path}","compare_url":"https://api.github.com/repos/mscdex/node/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mscdex/node/merges","archive_url":"https://api.github.com/repos/mscdex/node/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mscdex/node/downloads","issues_url":"https://api.github.com/repos/mscdex/node/issues{/number}","pulls_url":"https://api.github.com/repos/mscdex/node/pulls{/number}","milestones_url":"https://api.github.com/repos/mscdex/node/milestones{/number}","notifications_url":"https://api.github.com/repos/mscdex/node/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mscdex/node/labels{/name}","releases_url":"https://api.github.com/repos/mscdex/node/releases{/id}","created_at":"2013-12-26T18:11:45Z","updated_at":"2014-12-25T22:12:07Z","pushed_at":"2014-12-31T02:24:49Z","git_url":"git://github.com/mscdex/node.git","ssh_url":"git@github.com:mscdex/node.git","clone_url":"https://github.com/mscdex/node.git","svn_url":"https://github.com/mscdex/node","homepage":"http://nodejs.org/","size":110739,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":false,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"joyent:v0.12","ref":"v0.12","sha":"6a03fce16eaa4ec1085463d94734d40b370f3ea4","user":{"login":"joyent","id":10161,"avatar_url":"https://avatars.githubusercontent.com/u/10161?v=3","gravatar_id":"","url":"https://api.github.com/users/joyent","html_url":"https://github.com/joyent","followers_url":"https://api.github.com/users/joyent/followers","following_url":"https://api.github.com/users/joyent/following{/other_user}","gists_url":"https://api.github.com/users/joyent/gists{/gist_id}","starred_url":"https://api.github.com/users/joyent/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joyent/subscriptions","organizations_url":"https://api.github.com/users/joyent/orgs","repos_url":"https://api.github.com/users/joyent/repos","events_url":"https://api.github.com/users/joyent/events{/privacy}","received_events_url":"https://api.github.com/users/joyent/received_events","type":"Organization","site_admin":false},"repo":{"id":211666,"name":"node","full_name":"joyent/node","owner":{"login":"joyent","id":10161,"avatar_url":"https://avatars.githubusercontent.com/u/10161?v=3","gravatar_id":"","url":"https://api.github.com/users/joyent","html_url":"https://github.com/joyent","followers_url":"https://api.github.com/users/joyent/followers","following_url":"https://api.github.com/users/joyent/following{/other_user}","gists_url":"https://api.github.com/users/joyent/gists{/gist_id}","starred_url":"https://api.github.com/users/joyent/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joyent/subscriptions","organizations_url":"https://api.github.com/users/joyent/orgs","repos_url":"https://api.github.com/users/joyent/repos","events_url":"https://api.github.com/users/joyent/events{/privacy}","received_events_url":"https://api.github.com/users/joyent/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/joyent/node","description":"evented I/O for v8 javascript","fork":false,"url":"https://api.github.com/repos/joyent/node","forks_url":"https://api.github.com/repos/joyent/node/forks","keys_url":"https://api.github.com/repos/joyent/node/keys{/key_id}","collaborators_url":"https://api.github.com/repos/joyent/node/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/joyent/node/teams","hooks_url":"https://api.github.com/repos/joyent/node/hooks","issue_events_url":"https://api.github.com/repos/joyent/node/issues/events{/number}","events_url":"https://api.github.com/repos/joyent/node/events","assignees_url":"https://api.github.com/repos/joyent/node/assignees{/user}","branches_url":"https://api.github.com/repos/joyent/node/branches{/branch}","tags_url":"https://api.github.com/repos/joyent/node/tags","blobs_url":"https://api.github.com/repos/joyent/node/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/joyent/node/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/joyent/node/git/refs{/sha}","trees_url":"https://api.github.com/repos/joyent/node/git/trees{/sha}","statuses_url":"https://api.github.com/repos/joyent/node/statuses/{sha}","languages_url":"https://api.github.com/repos/joyent/node/languages","stargazers_url":"https://api.github.com/repos/joyent/node/stargazers","contributors_url":"https://api.github.com/repos/joyent/node/contributors","subscribers_url":"https://api.github.com/repos/joyent/node/subscribers","subscription_url":"https://api.github.com/repos/joyent/node/subscription","commits_url":"https://api.github.com/repos/joyent/node/commits{/sha}","git_commits_url":"https://api.github.com/repos/joyent/node/git/commits{/sha}","comments_url":"https://api.github.com/repos/joyent/node/comments{/number}","issue_comment_url":"https://api.github.com/repos/joyent/node/issues/comments/{number}","contents_url":"https://api.github.com/repos/joyent/node/contents/{+path}","compare_url":"https://api.github.com/repos/joyent/node/compare/{base}...{head}","merges_url":"https://api.github.com/repos/joyent/node/merges","archive_url":"https://api.github.com/repos/joyent/node/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/joyent/node/downloads","issues_url":"https://api.github.com/repos/joyent/node/issues{/number}","pulls_url":"https://api.github.com/repos/joyent/node/pulls{/number}","milestones_url":"https://api.github.com/repos/joyent/node/milestones{/number}","notifications_url":"https://api.github.com/repos/joyent/node/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/joyent/node/labels{/name}","releases_url":"https://api.github.com/repos/joyent/node/releases{/id}","created_at":"2009-05-27T16:29:46Z","updated_at":"2014-12-31T02:04:25Z","pushed_at":"2014-12-30T22:03:53Z","git_url":"git://github.com/joyent/node.git","ssh_url":"git@github.com:joyent/node.git","clone_url":"https://github.com/joyent/node.git","svn_url":"https://github.com/joyent/node","homepage":"http://nodejs.org/","size":491035,"stargazers_count":33968,"watchers_count":33968,"language":"JavaScript","has_issues":true,"has_downloads":false,"has_wiki":true,"has_pages":false,"forks_count":7604,"mirror_url":null,"open_issues_count":980,"forks":7604,"open_issues":980,"watchers":33968,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/joyent/node/pulls/8958"},"html":{"href":"https://github.com/joyent/node/pull/8958"},"issue":{"href":"https://api.github.com/repos/joyent/node/issues/8958"},"comments":{"href":"https://api.github.com/repos/joyent/node/issues/8958/comments"},"review_comments":{"href":"https://api.github.com/repos/joyent/node/pulls/8958/comments"},"review_comment":{"href":"https://api.github.com/repos/joyent/node/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/joyent/node/pulls/8958/commits"},"statuses":{"href":"https://api.github.com/repos/joyent/node/statuses/754dfd0ecdada5d4bc11c58e89950d2e5a45609e"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":1,"additions":19,"deletions":8,"changed_files":1}}