GitHub PullRequestEvent at 2014-12-18 17:01:58
Repository: http
Actor: JanTvrdik
Payload: {"action":"opened","number":33,"pull_request":{"url":"https://api.github.com/repos/nette/http/pulls/33","id":26315154,"html_url":"https://github.com/nette/http/pull/33","diff_url":"https://github.com/nette/http/pull/33.diff","patch_url":"https://github.com/nette/http/pull/33.patch","issue_url":"https://api.github.com/repos/nette/http/issues/33","number":33,"state":"open","locked":false,"title":"RequestFactory: optimized UTF-8 validation performance","user":{"login":"JanTvrdik","id":175109,"avatar_url":"https://avatars.githubusercontent.com/u/175109?v=3","gravatar_id":"","url":"https://api.github.com/users/JanTvrdik","html_url":"https://github.com/JanTvrdik","followers_url":"https://api.github.com/users/JanTvrdik/followers","following_url":"https://api.github.com/users/JanTvrdik/following{/other_user}","gists_url":"https://api.github.com/users/JanTvrdik/gists{/gist_id}","starred_url":"https://api.github.com/users/JanTvrdik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JanTvrdik/subscriptions","organizations_url":"https://api.github.com/users/JanTvrdik/orgs","repos_url":"https://api.github.com/users/JanTvrdik/repos","events_url":"https://api.github.com/users/JanTvrdik/events{/privacy}","received_events_url":"https://api.github.com/users/JanTvrdik/received_events","type":"User","site_admin":false},"body":"Benchmark:\r\n\r\n~~~php\r\n$s = str_repeat('a', 1e6) . 'b';\r\n$datasets = [\r\n\t'valid' => [$s, TRUE],\r\n\t'control character' => [str_replace('b', \"\\x00\", $s), FALSE],\r\n\t'invalid UTF-8' => [str_replace('b', \"\\xC0\", $s), FALSE],\r\n];\r\n\r\n$tests = [\r\n\t'NONCHARS' => function ($testCount, $s, $expected) {\r\n\t\tfor ($i = 0; $i < $testCount; $i++) {\r\n\t\t\t$actual = !preg_match('#[^\\x09\\x0A\\x0D\\x20-\\x7E\\xA0-\\x{10FFFF}]#u', $s) && !preg_last_error();\r\n\t\t}\r\n\t\tassert($actual === $expected);\r\n\t},\r\n\t'CHARS' => function ($testCount, $s, $expected) {\r\n\t\tfor ($i = 0; $i < $testCount; $i++) {\r\n\t\t\t$actual = preg_match('#^[\\x09\\x0A\\x0D\\x20-\\x7E\\xA0-\\x{10FFFF}]*\\z#u', $s) && !preg_last_error();\r\n\t\t}\r\n\t\tassert($actual === $expected);\r\n\t}\r\n];\r\n\r\n$testCount = 10;\r\n$padLength = max(array_map('strlen', array_keys($datasets))) + 3;\r\nforeach ($tests as $testName => $testCallback) {\r\n\tprintf(\"Test %s:\\n\", $testName);\r\n\tforeach ($datasets as $datasetName => $dataset) {\r\n\t\t$time = -microtime(TRUE);\r\n\t\t$testCallback($testCount, ...$dataset);\r\n\t\t$time += microtime(TRUE);\r\n\t\tprintf(\"  %s%5.0f ms\\n\", str_pad($datasetName, $padLength), $time * 1e3);\r\n\t}\r\n\tprintf(\"\\n\");\r\n}\r\n~~~\r\n\r\nResults:\r\n~~~\r\nTest NONCHARS:\r\n  valid                 252 ms\r\n  control character     248 ms\r\n  invalid UTF-8           6 ms\r\n\r\nTest CHARS:\r\n  valid                  54 ms\r\n  control character     147 ms\r\n  invalid UTF-8           7 ms\r\n~~~","created_at":"2014-12-18T17:01:57Z","updated_at":"2014-12-18T17:01:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"71767faab63acc6ce72e95e921da1cd4577f8764","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/nette/http/pulls/33/commits","review_comments_url":"https://api.github.com/repos/nette/http/pulls/33/comments","review_comment_url":"https://api.github.com/repos/nette/http/pulls/comments/{number}","comments_url":"https://api.github.com/repos/nette/http/issues/33/comments","statuses_url":"https://api.github.com/repos/nette/http/statuses/b6f3a9db289a82b90e362c30f8c6264500cf31e0","head":{"label":"JanTvrdik:request_factory_nonchars_performance","ref":"request_factory_nonchars_performance","sha":"b6f3a9db289a82b90e362c30f8c6264500cf31e0","user":{"login":"JanTvrdik","id":175109,"avatar_url":"https://avatars.githubusercontent.com/u/175109?v=3","gravatar_id":"","url":"https://api.github.com/users/JanTvrdik","html_url":"https://github.com/JanTvrdik","followers_url":"https://api.github.com/users/JanTvrdik/followers","following_url":"https://api.github.com/users/JanTvrdik/following{/other_user}","gists_url":"https://api.github.com/users/JanTvrdik/gists{/gist_id}","starred_url":"https://api.github.com/users/JanTvrdik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JanTvrdik/subscriptions","organizations_url":"https://api.github.com/users/JanTvrdik/orgs","repos_url":"https://api.github.com/users/JanTvrdik/repos","events_url":"https://api.github.com/users/JanTvrdik/events{/privacy}","received_events_url":"https://api.github.com/users/JanTvrdik/received_events","type":"User","site_admin":false},"repo":{"id":21949120,"name":"nette-http","full_name":"JanTvrdik/nette-http","owner":{"login":"JanTvrdik","id":175109,"avatar_url":"https://avatars.githubusercontent.com/u/175109?v=3","gravatar_id":"","url":"https://api.github.com/users/JanTvrdik","html_url":"https://github.com/JanTvrdik","followers_url":"https://api.github.com/users/JanTvrdik/followers","following_url":"https://api.github.com/users/JanTvrdik/following{/other_user}","gists_url":"https://api.github.com/users/JanTvrdik/gists{/gist_id}","starred_url":"https://api.github.com/users/JanTvrdik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JanTvrdik/subscriptions","organizations_url":"https://api.github.com/users/JanTvrdik/orgs","repos_url":"https://api.github.com/users/JanTvrdik/repos","events_url":"https://api.github.com/users/JanTvrdik/events{/privacy}","received_events_url":"https://api.github.com/users/JanTvrdik/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/JanTvrdik/nette-http","description":"Nette HTTP Component","fork":true,"url":"https://api.github.com/repos/JanTvrdik/nette-http","forks_url":"https://api.github.com/repos/JanTvrdik/nette-http/forks","keys_url":"https://api.github.com/repos/JanTvrdik/nette-http/keys{/key_id}","collaborators_url":"https://api.github.com/repos/JanTvrdik/nette-http/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/JanTvrdik/nette-http/teams","hooks_url":"https://api.github.com/repos/JanTvrdik/nette-http/hooks","issue_events_url":"https://api.github.com/repos/JanTvrdik/nette-http/issues/events{/number}","events_url":"https://api.github.com/repos/JanTvrdik/nette-http/events","assignees_url":"https://api.github.com/repos/JanTvrdik/nette-http/assignees{/user}","branches_url":"https://api.github.com/repos/JanTvrdik/nette-http/branches{/branch}","tags_url":"https://api.github.com/repos/JanTvrdik/nette-http/tags","blobs_url":"https://api.github.com/repos/JanTvrdik/nette-http/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/JanTvrdik/nette-http/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/JanTvrdik/nette-http/git/refs{/sha}","trees_url":"https://api.github.com/repos/JanTvrdik/nette-http/git/trees{/sha}","statuses_url":"https://api.github.com/repos/JanTvrdik/nette-http/statuses/{sha}","languages_url":"https://api.github.com/repos/JanTvrdik/nette-http/languages","stargazers_url":"https://api.github.com/repos/JanTvrdik/nette-http/stargazers","contributors_url":"https://api.github.com/repos/JanTvrdik/nette-http/contributors","subscribers_url":"https://api.github.com/repos/JanTvrdik/nette-http/subscribers","subscription_url":"https://api.github.com/repos/JanTvrdik/nette-http/subscription","commits_url":"https://api.github.com/repos/JanTvrdik/nette-http/commits{/sha}","git_commits_url":"https://api.github.com/repos/JanTvrdik/nette-http/git/commits{/sha}","comments_url":"https://api.github.com/repos/JanTvrdik/nette-http/comments{/number}","issue_comment_url":"https://api.github.com/repos/JanTvrdik/nette-http/issues/comments/{number}","contents_url":"https://api.github.com/repos/JanTvrdik/nette-http/contents/{+path}","compare_url":"https://api.github.com/repos/JanTvrdik/nette-http/compare/{base}...{head}","merges_url":"https://api.github.com/repos/JanTvrdik/nette-http/merges","archive_url":"https://api.github.com/repos/JanTvrdik/nette-http/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/JanTvrdik/nette-http/downloads","issues_url":"https://api.github.com/repos/JanTvrdik/nette-http/issues{/number}","pulls_url":"https://api.github.com/repos/JanTvrdik/nette-http/pulls{/number}","milestones_url":"https://api.github.com/repos/JanTvrdik/nette-http/milestones{/number}","notifications_url":"https://api.github.com/repos/JanTvrdik/nette-http/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/JanTvrdik/nette-http/labels{/name}","releases_url":"https://api.github.com/repos/JanTvrdik/nette-http/releases{/id}","created_at":"2014-07-17T16:23:12Z","updated_at":"2014-07-17T16:23:30Z","pushed_at":"2014-12-18T17:00:44Z","git_url":"git://github.com/JanTvrdik/nette-http.git","ssh_url":"git@github.com:JanTvrdik/nette-http.git","clone_url":"https://github.com/JanTvrdik/nette-http.git","svn_url":"https://github.com/JanTvrdik/nette-http","homepage":"http://nette.org","size":517,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":false,"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":"nette:master","ref":"master","sha":"88784b1d2ce236bead3cc1c6717fbc8865775307","user":{"login":"nette","id":99965,"avatar_url":"https://avatars.githubusercontent.com/u/99965?v=3","gravatar_id":"","url":"https://api.github.com/users/nette","html_url":"https://github.com/nette","followers_url":"https://api.github.com/users/nette/followers","following_url":"https://api.github.com/users/nette/following{/other_user}","gists_url":"https://api.github.com/users/nette/gists{/gist_id}","starred_url":"https://api.github.com/users/nette/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nette/subscriptions","organizations_url":"https://api.github.com/users/nette/orgs","repos_url":"https://api.github.com/users/nette/repos","events_url":"https://api.github.com/users/nette/events{/privacy}","received_events_url":"https://api.github.com/users/nette/received_events","type":"Organization","site_admin":false},"repo":{"id":17694028,"name":"http","full_name":"nette/http","owner":{"login":"nette","id":99965,"avatar_url":"https://avatars.githubusercontent.com/u/99965?v=3","gravatar_id":"","url":"https://api.github.com/users/nette","html_url":"https://github.com/nette","followers_url":"https://api.github.com/users/nette/followers","following_url":"https://api.github.com/users/nette/following{/other_user}","gists_url":"https://api.github.com/users/nette/gists{/gist_id}","starred_url":"https://api.github.com/users/nette/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nette/subscriptions","organizations_url":"https://api.github.com/users/nette/orgs","repos_url":"https://api.github.com/users/nette/repos","events_url":"https://api.github.com/users/nette/events{/privacy}","received_events_url":"https://api.github.com/users/nette/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/nette/http","description":"Nette HTTP Component","fork":false,"url":"https://api.github.com/repos/nette/http","forks_url":"https://api.github.com/repos/nette/http/forks","keys_url":"https://api.github.com/repos/nette/http/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nette/http/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nette/http/teams","hooks_url":"https://api.github.com/repos/nette/http/hooks","issue_events_url":"https://api.github.com/repos/nette/http/issues/events{/number}","events_url":"https://api.github.com/repos/nette/http/events","assignees_url":"https://api.github.com/repos/nette/http/assignees{/user}","branches_url":"https://api.github.com/repos/nette/http/branches{/branch}","tags_url":"https://api.github.com/repos/nette/http/tags","blobs_url":"https://api.github.com/repos/nette/http/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nette/http/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nette/http/git/refs{/sha}","trees_url":"https://api.github.com/repos/nette/http/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nette/http/statuses/{sha}","languages_url":"https://api.github.com/repos/nette/http/languages","stargazers_url":"https://api.github.com/repos/nette/http/stargazers","contributors_url":"https://api.github.com/repos/nette/http/contributors","subscribers_url":"https://api.github.com/repos/nette/http/subscribers","subscription_url":"https://api.github.com/repos/nette/http/subscription","commits_url":"https://api.github.com/repos/nette/http/commits{/sha}","git_commits_url":"https://api.github.com/repos/nette/http/git/commits{/sha}","comments_url":"https://api.github.com/repos/nette/http/comments{/number}","issue_comment_url":"https://api.github.com/repos/nette/http/issues/comments/{number}","contents_url":"https://api.github.com/repos/nette/http/contents/{+path}","compare_url":"https://api.github.com/repos/nette/http/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nette/http/merges","archive_url":"https://api.github.com/repos/nette/http/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nette/http/downloads","issues_url":"https://api.github.com/repos/nette/http/issues{/number}","pulls_url":"https://api.github.com/repos/nette/http/pulls{/number}","milestones_url":"https://api.github.com/repos/nette/http/milestones{/number}","notifications_url":"https://api.github.com/repos/nette/http/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nette/http/labels{/name}","releases_url":"https://api.github.com/repos/nette/http/releases{/id}","created_at":"2014-03-13T03:46:16Z","updated_at":"2014-12-11T15:04:23Z","pushed_at":"2014-12-14T19:43:37Z","git_url":"git://github.com/nette/http.git","ssh_url":"git@github.com:nette/http.git","clone_url":"https://github.com/nette/http.git","svn_url":"https://github.com/nette/http","homepage":"http://nette.org","size":925,"stargazers_count":56,"watchers_count":56,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":12,"mirror_url":null,"open_issues_count":14,"forks":12,"open_issues":14,"watchers":56,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/nette/http/pulls/33"},"html":{"href":"https://github.com/nette/http/pull/33"},"issue":{"href":"https://api.github.com/repos/nette/http/issues/33"},"comments":{"href":"https://api.github.com/repos/nette/http/issues/33/comments"},"review_comments":{"href":"https://api.github.com/repos/nette/http/pulls/33/comments"},"review_comment":{"href":"https://api.github.com/repos/nette/http/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/nette/http/pulls/33/commits"},"statuses":{"href":"https://api.github.com/repos/nette/http/statuses/b6f3a9db289a82b90e362c30f8c6264500cf31e0"}},"merged":false,"mergeable":true,"mergeable_state":"clean","merged_by":null,"comments":0,"review_comments":0,"commits":1,"additions":6,"deletions":6,"changed_files":1}}