{"action":"created","comment":{"url":"https://api.github.com/repos/grpc/grpc-go/pulls/comments/61503182","id":61503182,"diff_hunk":"@@ -0,0 +1,330 @@\n+/*\n+ *\n+ * Copyright 2016, Google Inc.\n+ * All rights reserved.\n+ *\n+ * Redistribution and use in source and binary forms, with or without\n+ * modification, are permitted provided that the following conditions are\n+ * met:\n+ *\n+ *     * Redistributions of source code must retain the above copyright\n+ * notice, this list of conditions and the following disclaimer.\n+ *     * Redistributions in binary form must reproduce the above\n+ * copyright notice, this list of conditions and the following disclaimer\n+ * in the documentation and/or other materials provided with the\n+ * distribution.\n+ *     * Neither the name of Google Inc. nor the names of its\n+ * contributors may be used to endorse or promote products derived from\n+ * this software without specific prior written permission.\n+ *\n+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n+ * \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n+ *\n+ */\n+\n+package main\n+\n+import (\n+\t\"math\"\n+\t\"runtime\"\n+\t\"sync\"\n+\t\"time\"\n+\n+\t\"golang.org/x/net/context\"\n+\t\"google.golang.org/grpc\"\n+\t\"google.golang.org/grpc/benchmark\"\n+\ttestpb \"google.golang.org/grpc/benchmark/grpc_testing\"\n+\t\"google.golang.org/grpc/benchmark/stats\"\n+\t\"google.golang.org/grpc/codes\"\n+\t\"google.golang.org/grpc/credentials\"\n+\t\"google.golang.org/grpc/grpclog\"\n+)\n+\n+var (\n+\tcaFile = \"benchmark/server/testdata/ca.pem\"\n+)\n+\n+type benchmarkClient struct {\n+\tstop          chan bool\n+\tmu            sync.RWMutex\n+\tlastResetTime time.Time\n+\thistogram     *stats.Histogram\n+}\n+\n+func startBenchmarkClientWithSetup(setup *testpb.ClientConfig) (*benchmarkClient, error) {\n+\tvar opts []grpc.DialOption\n+\n+\t// Some setup options are ignored:\n+\t// - client type:\n+\t//     will always create sync client\n+\t// - async client threads.\n+\t// - core list\n+\tgrpclog.Printf(\" * client type: %v (ignored, always creates sync client)\", setup.ClientType)\n+\tswitch setup.ClientType {\n+\tcase testpb.ClientType_SYNC_CLIENT:\n+\tcase testpb.ClientType_ASYNC_CLIENT:\n+\tdefault:\n+\t\treturn nil, grpc.Errorf(codes.InvalidArgument, \"unknow client type: %v\", setup.ClientType)\n+\t}\n+\tgrpclog.Printf(\" * async client threads: %v (ignored)\", setup.AsyncClientThreads)\n+\tgrpclog.Printf(\" * core list: %v (ignored)\", setup.CoreList)\n+\n+\tgrpclog.Printf(\" - security params: %v\", setup.SecurityParams)\n+\tif setup.SecurityParams != nil {\n+\t\tcreds, err := credentials.NewClientTLSFromFile(Abs(caFile), setup.SecurityParams.ServerHostOverride)\n+\t\tif err != nil {\n+\t\t\treturn nil, grpc.Errorf(codes.InvalidArgument, \"failed to create TLS credentials %v\", err)\n+\t\t}\n+\t\topts = append(opts, grpc.WithTransportCredentials(creds))\n+\t} else {\n+\t\topts = append(opts, grpc.WithInsecure())\n+\t}\n+\n+\tgrpclog.Printf(\" - core limit: %v\", setup.CoreLimit)\n+\t// Use one cpu core by default\n+\tnumOfCores := 1\n+\tif setup.CoreLimit > 0 {\n+\t\tnumOfCores = int(setup.CoreLimit)\n+\t}\n+\truntime.GOMAXPROCS(numOfCores)\n+\n+\tgrpclog.Printf(\" - payload config: %v\", setup.PayloadConfig)\n+\tvar payloadReqSize, payloadRespSize int\n+\tvar payloadType string\n+\tif setup.PayloadConfig != nil {\n+\t\tswitch c := setup.PayloadConfig.Payload.(type) {\n+\t\tcase *testpb.PayloadConfig_BytebufParams:\n+\t\t\topts = append(opts, grpc.WithCodec(byteBufCodec{}))\n+\t\t\tpayloadReqSize = int(c.BytebufParams.ReqSize)\n+\t\t\tpayloadRespSize = int(c.BytebufParams.RespSize)\n+\t\t\tpayloadType = \"bytebuf\"\n+\t\tcase *testpb.PayloadConfig_SimpleParams:\n+\t\t\tpayloadReqSize = int(c.SimpleParams.ReqSize)\n+\t\t\tpayloadRespSize = int(c.SimpleParams.RespSize)\n+\t\t\tpayloadType = \"protobuf\"\n+\t\tcase *testpb.PayloadConfig_ComplexParams:\n+\t\t\treturn nil, grpc.Errorf(codes.Unimplemented, \"unsupported payload config: %v\", setup.PayloadConfig)\n+\t\tdefault:\n+\t\t\treturn nil, grpc.Errorf(codes.InvalidArgument, \"unknow payload config: %v\", setup.PayloadConfig)\n+\t\t}\n+\t}\n+\n+\tgrpclog.Printf(\" - rpcs per chann: %v\", setup.OutstandingRpcsPerChannel)\n+\tgrpclog.Printf(\" - channel number: %v\", setup.ClientChannels)\n+\n+\trpcCountPerConn, connCount := int(setup.OutstandingRpcsPerChannel), int(setup.ClientChannels)\n+\n+\tgrpclog.Printf(\" - load params: %v\", setup.LoadParams)\n+\tvar dist *int","path":"benchmark/worker/benchmark_client.go","position":127,"original_position":127,"commit_id":"63410e345381482c8f4cec67f2f7f71ed6d7da34","original_commit_id":"63410e345381482c8f4cec67f2f7f71ed6d7da34","user":{"login":"iamqizhao","id":10121772,"avatar_url":"https://avatars.githubusercontent.com/u/10121772?v=3","gravatar_id":"","url":"https://api.github.com/users/iamqizhao","html_url":"https://github.com/iamqizhao","followers_url":"https://api.github.com/users/iamqizhao/followers","following_url":"https://api.github.com/users/iamqizhao/following{/other_user}","gists_url":"https://api.github.com/users/iamqizhao/gists{/gist_id}","starred_url":"https://api.github.com/users/iamqizhao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iamqizhao/subscriptions","organizations_url":"https://api.github.com/users/iamqizhao/orgs","repos_url":"https://api.github.com/users/iamqizhao/repos","events_url":"https://api.github.com/users/iamqizhao/events{/privacy}","received_events_url":"https://api.github.com/users/iamqizhao/received_events","type":"User","site_admin":false},"body":"remove the relevant code if it is NOT supported yet.","created_at":"2016-04-28T21:11:07Z","updated_at":"2016-04-28T21:11:07Z","html_url":"https://github.com/grpc/grpc-go/pull/660#discussion_r61503182","pull_request_url":"https://api.github.com/repos/grpc/grpc-go/pulls/660","_links":{"self":{"href":"https://api.github.com/repos/grpc/grpc-go/pulls/comments/61503182"},"html":{"href":"https://github.com/grpc/grpc-go/pull/660#discussion_r61503182"},"pull_request":{"href":"https://api.github.com/repos/grpc/grpc-go/pulls/660"}}},"pull_request":{"url":"https://api.github.com/repos/grpc/grpc-go/pulls/660","id":68140147,"html_url":"https://github.com/grpc/grpc-go/pull/660","diff_url":"https://github.com/grpc/grpc-go/pull/660.diff","patch_url":"https://github.com/grpc/grpc-go/pull/660.patch","issue_url":"https://api.github.com/repos/grpc/grpc-go/issues/660","number":660,"state":"open","locked":false,"title":"Benchmark worker","user":{"login":"menghanl","id":960845,"avatar_url":"https://avatars.githubusercontent.com/u/960845?v=3","gravatar_id":"","url":"https://api.github.com/users/menghanl","html_url":"https://github.com/menghanl","followers_url":"https://api.github.com/users/menghanl/followers","following_url":"https://api.github.com/users/menghanl/following{/other_user}","gists_url":"https://api.github.com/users/menghanl/gists{/gist_id}","starred_url":"https://api.github.com/users/menghanl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/menghanl/subscriptions","organizations_url":"https://api.github.com/users/menghanl/orgs","repos_url":"https://api.github.com/users/menghanl/repos","events_url":"https://api.github.com/users/menghanl/events{/privacy}","received_events_url":"https://api.github.com/users/menghanl/received_events","type":"User","site_admin":false},"body":"Updates #454 ","created_at":"2016-04-27T23:10:33Z","updated_at":"2016-04-28T21:11:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0268ea7d077f0b73ed1f656e8ca91c1db908d439","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/grpc/grpc-go/pulls/660/commits","review_comments_url":"https://api.github.com/repos/grpc/grpc-go/pulls/660/comments","review_comment_url":"https://api.github.com/repos/grpc/grpc-go/pulls/comments{/number}","comments_url":"https://api.github.com/repos/grpc/grpc-go/issues/660/comments","statuses_url":"https://api.github.com/repos/grpc/grpc-go/statuses/63410e345381482c8f4cec67f2f7f71ed6d7da34","head":{"label":"menghanl:benchmark_client","ref":"benchmark_client","sha":"63410e345381482c8f4cec67f2f7f71ed6d7da34","user":{"login":"menghanl","id":960845,"avatar_url":"https://avatars.githubusercontent.com/u/960845?v=3","gravatar_id":"","url":"https://api.github.com/users/menghanl","html_url":"https://github.com/menghanl","followers_url":"https://api.github.com/users/menghanl/followers","following_url":"https://api.github.com/users/menghanl/following{/other_user}","gists_url":"https://api.github.com/users/menghanl/gists{/gist_id}","starred_url":"https://api.github.com/users/menghanl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/menghanl/subscriptions","organizations_url":"https://api.github.com/users/menghanl/orgs","repos_url":"https://api.github.com/users/menghanl/repos","events_url":"https://api.github.com/users/menghanl/events{/privacy}","received_events_url":"https://api.github.com/users/menghanl/received_events","type":"User","site_admin":false},"repo":{"id":54156883,"name":"grpc-go","full_name":"menghanl/grpc-go","owner":{"login":"menghanl","id":960845,"avatar_url":"https://avatars.githubusercontent.com/u/960845?v=3","gravatar_id":"","url":"https://api.github.com/users/menghanl","html_url":"https://github.com/menghanl","followers_url":"https://api.github.com/users/menghanl/followers","following_url":"https://api.github.com/users/menghanl/following{/other_user}","gists_url":"https://api.github.com/users/menghanl/gists{/gist_id}","starred_url":"https://api.github.com/users/menghanl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/menghanl/subscriptions","organizations_url":"https://api.github.com/users/menghanl/orgs","repos_url":"https://api.github.com/users/menghanl/repos","events_url":"https://api.github.com/users/menghanl/events{/privacy}","received_events_url":"https://api.github.com/users/menghanl/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/menghanl/grpc-go","description":"The Go language implementation of gRPC. HTTP/2 based RPC","fork":true,"url":"https://api.github.com/repos/menghanl/grpc-go","forks_url":"https://api.github.com/repos/menghanl/grpc-go/forks","keys_url":"https://api.github.com/repos/menghanl/grpc-go/keys{/key_id}","collaborators_url":"https://api.github.com/repos/menghanl/grpc-go/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/menghanl/grpc-go/teams","hooks_url":"https://api.github.com/repos/menghanl/grpc-go/hooks","issue_events_url":"https://api.github.com/repos/menghanl/grpc-go/issues/events{/number}","events_url":"https://api.github.com/repos/menghanl/grpc-go/events","assignees_url":"https://api.github.com/repos/menghanl/grpc-go/assignees{/user}","branches_url":"https://api.github.com/repos/menghanl/grpc-go/branches{/branch}","tags_url":"https://api.github.com/repos/menghanl/grpc-go/tags","blobs_url":"https://api.github.com/repos/menghanl/grpc-go/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/menghanl/grpc-go/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/menghanl/grpc-go/git/refs{/sha}","trees_url":"https://api.github.com/repos/menghanl/grpc-go/git/trees{/sha}","statuses_url":"https://api.github.com/repos/menghanl/grpc-go/statuses/{sha}","languages_url":"https://api.github.com/repos/menghanl/grpc-go/languages","stargazers_url":"https://api.github.com/repos/menghanl/grpc-go/stargazers","contributors_url":"https://api.github.com/repos/menghanl/grpc-go/contributors","subscribers_url":"https://api.github.com/repos/menghanl/grpc-go/subscribers","subscription_url":"https://api.github.com/repos/menghanl/grpc-go/subscription","commits_url":"https://api.github.com/repos/menghanl/grpc-go/commits{/sha}","git_commits_url":"https://api.github.com/repos/menghanl/grpc-go/git/commits{/sha}","comments_url":"https://api.github.com/repos/menghanl/grpc-go/comments{/number}","issue_comment_url":"https://api.github.com/repos/menghanl/grpc-go/issues/comments{/number}","contents_url":"https://api.github.com/repos/menghanl/grpc-go/contents/{+path}","compare_url":"https://api.github.com/repos/menghanl/grpc-go/compare/{base}...{head}","merges_url":"https://api.github.com/repos/menghanl/grpc-go/merges","archive_url":"https://api.github.com/repos/menghanl/grpc-go/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/menghanl/grpc-go/downloads","issues_url":"https://api.github.com/repos/menghanl/grpc-go/issues{/number}","pulls_url":"https://api.github.com/repos/menghanl/grpc-go/pulls{/number}","milestones_url":"https://api.github.com/repos/menghanl/grpc-go/milestones{/number}","notifications_url":"https://api.github.com/repos/menghanl/grpc-go/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/menghanl/grpc-go/labels{/name}","releases_url":"https://api.github.com/repos/menghanl/grpc-go/releases{/id}","deployments_url":"https://api.github.com/repos/menghanl/grpc-go/deployments","created_at":"2016-03-17T22:55:39Z","updated_at":"2016-03-17T22:55:40Z","pushed_at":"2016-04-27T23:15:32Z","git_url":"git://github.com/menghanl/grpc-go.git","ssh_url":"git@github.com:menghanl/grpc-go.git","clone_url":"https://github.com/menghanl/grpc-go.git","svn_url":"https://github.com/menghanl/grpc-go","homepage":"","size":1707,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":false,"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":"grpc:master","ref":"master","sha":"b062a3c003c22bfef58fa99d689e6a892b408f9d","user":{"login":"grpc","id":7802525,"avatar_url":"https://avatars.githubusercontent.com/u/7802525?v=3","gravatar_id":"","url":"https://api.github.com/users/grpc","html_url":"https://github.com/grpc","followers_url":"https://api.github.com/users/grpc/followers","following_url":"https://api.github.com/users/grpc/following{/other_user}","gists_url":"https://api.github.com/users/grpc/gists{/gist_id}","starred_url":"https://api.github.com/users/grpc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grpc/subscriptions","organizations_url":"https://api.github.com/users/grpc/orgs","repos_url":"https://api.github.com/users/grpc/repos","events_url":"https://api.github.com/users/grpc/events{/privacy}","received_events_url":"https://api.github.com/users/grpc/received_events","type":"Organization","site_admin":false},"repo":{"id":27729907,"name":"grpc-go","full_name":"grpc/grpc-go","owner":{"login":"grpc","id":7802525,"avatar_url":"https://avatars.githubusercontent.com/u/7802525?v=3","gravatar_id":"","url":"https://api.github.com/users/grpc","html_url":"https://github.com/grpc","followers_url":"https://api.github.com/users/grpc/followers","following_url":"https://api.github.com/users/grpc/following{/other_user}","gists_url":"https://api.github.com/users/grpc/gists{/gist_id}","starred_url":"https://api.github.com/users/grpc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grpc/subscriptions","organizations_url":"https://api.github.com/users/grpc/orgs","repos_url":"https://api.github.com/users/grpc/repos","events_url":"https://api.github.com/users/grpc/events{/privacy}","received_events_url":"https://api.github.com/users/grpc/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/grpc/grpc-go","description":"The Go language implementation of gRPC. HTTP/2 based RPC","fork":false,"url":"https://api.github.com/repos/grpc/grpc-go","forks_url":"https://api.github.com/repos/grpc/grpc-go/forks","keys_url":"https://api.github.com/repos/grpc/grpc-go/keys{/key_id}","collaborators_url":"https://api.github.com/repos/grpc/grpc-go/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/grpc/grpc-go/teams","hooks_url":"https://api.github.com/repos/grpc/grpc-go/hooks","issue_events_url":"https://api.github.com/repos/grpc/grpc-go/issues/events{/number}","events_url":"https://api.github.com/repos/grpc/grpc-go/events","assignees_url":"https://api.github.com/repos/grpc/grpc-go/assignees{/user}","branches_url":"https://api.github.com/repos/grpc/grpc-go/branches{/branch}","tags_url":"https://api.github.com/repos/grpc/grpc-go/tags","blobs_url":"https://api.github.com/repos/grpc/grpc-go/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/grpc/grpc-go/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/grpc/grpc-go/git/refs{/sha}","trees_url":"https://api.github.com/repos/grpc/grpc-go/git/trees{/sha}","statuses_url":"https://api.github.com/repos/grpc/grpc-go/statuses/{sha}","languages_url":"https://api.github.com/repos/grpc/grpc-go/languages","stargazers_url":"https://api.github.com/repos/grpc/grpc-go/stargazers","contributors_url":"https://api.github.com/repos/grpc/grpc-go/contributors","subscribers_url":"https://api.github.com/repos/grpc/grpc-go/subscribers","subscription_url":"https://api.github.com/repos/grpc/grpc-go/subscription","commits_url":"https://api.github.com/repos/grpc/grpc-go/commits{/sha}","git_commits_url":"https://api.github.com/repos/grpc/grpc-go/git/commits{/sha}","comments_url":"https://api.github.com/repos/grpc/grpc-go/comments{/number}","issue_comment_url":"https://api.github.com/repos/grpc/grpc-go/issues/comments{/number}","contents_url":"https://api.github.com/repos/grpc/grpc-go/contents/{+path}","compare_url":"https://api.github.com/repos/grpc/grpc-go/compare/{base}...{head}","merges_url":"https://api.github.com/repos/grpc/grpc-go/merges","archive_url":"https://api.github.com/repos/grpc/grpc-go/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/grpc/grpc-go/downloads","issues_url":"https://api.github.com/repos/grpc/grpc-go/issues{/number}","pulls_url":"https://api.github.com/repos/grpc/grpc-go/pulls{/number}","milestones_url":"https://api.github.com/repos/grpc/grpc-go/milestones{/number}","notifications_url":"https://api.github.com/repos/grpc/grpc-go/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/grpc/grpc-go/labels{/name}","releases_url":"https://api.github.com/repos/grpc/grpc-go/releases{/id}","deployments_url":"https://api.github.com/repos/grpc/grpc-go/deployments","created_at":"2014-12-08T18:59:34Z","updated_at":"2016-04-28T17:13:27Z","pushed_at":"2016-04-27T23:15:32Z","git_url":"git://github.com/grpc/grpc-go.git","ssh_url":"git@github.com:grpc/grpc-go.git","clone_url":"https://github.com/grpc/grpc-go.git","svn_url":"https://github.com/grpc/grpc-go","homepage":"","size":2302,"stargazers_count":1703,"watchers_count":1703,"language":"Go","has_issues":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":247,"mirror_url":null,"open_issues_count":59,"forks":247,"open_issues":59,"watchers":1703,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/grpc/grpc-go/pulls/660"},"html":{"href":"https://github.com/grpc/grpc-go/pull/660"},"issue":{"href":"https://api.github.com/repos/grpc/grpc-go/issues/660"},"comments":{"href":"https://api.github.com/repos/grpc/grpc-go/issues/660/comments"},"review_comments":{"href":"https://api.github.com/repos/grpc/grpc-go/pulls/660/comments"},"review_comment":{"href":"https://api.github.com/repos/grpc/grpc-go/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/grpc/grpc-go/pulls/660/commits"},"statuses":{"href":"https://api.github.com/repos/grpc/grpc-go/statuses/63410e345381482c8f4cec67f2f7f71ed6d7da34"}}}}