{"action":"created","comment":{"url":"https://api.github.com/repos/google/benchmark/pulls/comments/64268930","id":64268930,"diff_hunk":"@@ -77,6 +79,74 @@ void BenchmarkReporter::ComputeStats(\n   stddev_data->items_per_second = items_per_second_stat.StdDev();\n }\n \n+void BenchmarkReporter::ComputeBigO(\n+    const std::vector<Run>& reports,\n+    Run* big_o, Run* rms) {\n+  CHECK(reports.size() >= 2) << \"Cannot compute asymptotic complexity for less than 2 reports\";\n+  // Accumulators.\n+  std::vector<int> n;\n+  std::vector<double> real_time;\n+  std::vector<double> cpu_time;\n+\n+  // Populate the accumulators.\n+  for (const Run& run : reports) {\n+    n.push_back(run.arg1); \n+    real_time.push_back(run.real_accumulated_time/run.iterations);\n+    cpu_time.push_back(run.cpu_accumulated_time/run.iterations);\n+  }\n+  \n+  LeastSq result_cpu = MinimalLeastSq(n, cpu_time, reports[0].complexity);\n+  \n+  // result_cpu.complexity is passed as parameter to result_real because in case\n+  // reports[0].complexity is oAuto, the noise on the measured data could make \n+  // the best fit function of Cpu and Real differ. In order to solve this, we take\n+  // the best fitting function for the Cpu, and apply it to Real data.\n+  LeastSq result_real = MinimalLeastSq(n, real_time, result_cpu.complexity);\n+\n+  std::string benchmark_name = reports[0].benchmark_name.substr(0, reports[0].benchmark_name.find('/'));\n+  \n+  // Get the data from the accumulator to BenchmarkReporter::Run's.\n+  big_o->benchmark_name = benchmark_name + \"_BigO\";\n+  big_o->iterations = 0;\n+  big_o->real_accumulated_time = result_real.coef;\n+  big_o->cpu_accumulated_time = result_cpu.coef;\n+  big_o->report_big_o = true;\n+  big_o->complexity = result_cpu.complexity;\n+\n+  double multiplier;\n+  const char* time_label;\n+  std::tie(time_label, multiplier) = GetTimeUnitAndMultiplier(reports[0].time_unit);\n+\n+  // Only add label to mean/stddev if it is same for all runs\n+  big_o->report_label = reports[0].report_label;\n+  rms->benchmark_name = benchmark_name + \"_RMS\";\n+  rms->report_label = big_o->report_label;\n+  rms->iterations = 0;\n+  rms->real_accumulated_time = result_real.rms / multiplier;\n+  rms->cpu_accumulated_time = result_cpu.rms / multiplier;\n+  rms->report_rms = true;\n+  rms->complexity = result_cpu.complexity;\n+}\n+\n+std::string BenchmarkReporter::GetBigO(BigO complexity) {\n+  switch (complexity) {","path":"src/reporter.cc","position":66,"original_position":66,"commit_id":"43ef17441cc8767f5523031878a2f43ab1d7790b","original_commit_id":"43ef17441cc8767f5523031878a2f43ab1d7790b","user":{"login":"dominichamon","id":510002,"avatar_url":"https://avatars.githubusercontent.com/u/510002?v=3","gravatar_id":"","url":"https://api.github.com/users/dominichamon","html_url":"https://github.com/dominichamon","followers_url":"https://api.github.com/users/dominichamon/followers","following_url":"https://api.github.com/users/dominichamon/following{/other_user}","gists_url":"https://api.github.com/users/dominichamon/gists{/gist_id}","starred_url":"https://api.github.com/users/dominichamon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dominichamon/subscriptions","organizations_url":"https://api.github.com/users/dominichamon/orgs","repos_url":"https://api.github.com/users/dominichamon/repos","events_url":"https://api.github.com/users/dominichamon/events{/privacy}","received_events_url":"https://api.github.com/users/dominichamon/received_events","type":"User","site_admin":false},"body":"the code /might/ be simpler if the definition of the BigO enum, this method, and FittingCurve, are moved into their own files. That keeps all of the complexity methods together and allows this file to focus on things specific to the reporter, which this isn't.","created_at":"2016-05-23T18:55:32Z","updated_at":"2016-05-23T18:55:32Z","html_url":"https://github.com/google/benchmark/pull/215#discussion_r64268930","pull_request_url":"https://api.github.com/repos/google/benchmark/pulls/215","_links":{"self":{"href":"https://api.github.com/repos/google/benchmark/pulls/comments/64268930"},"html":{"href":"https://github.com/google/benchmark/pull/215#discussion_r64268930"},"pull_request":{"href":"https://api.github.com/repos/google/benchmark/pulls/215"}}},"pull_request":{"url":"https://api.github.com/repos/google/benchmark/pulls/215","id":70951518,"html_url":"https://github.com/google/benchmark/pull/215","diff_url":"https://github.com/google/benchmark/pull/215.diff","patch_url":"https://github.com/google/benchmark/pull/215.patch","issue_url":"https://api.github.com/repos/google/benchmark/issues/215","number":215,"state":"open","locked":false,"title":"Add reporting of asymptotic complexity and NRMSE","user":{"login":"ismaelJimenez","id":712805,"avatar_url":"https://avatars.githubusercontent.com/u/712805?v=3","gravatar_id":"","url":"https://api.github.com/users/ismaelJimenez","html_url":"https://github.com/ismaelJimenez","followers_url":"https://api.github.com/users/ismaelJimenez/followers","following_url":"https://api.github.com/users/ismaelJimenez/following{/other_user}","gists_url":"https://api.github.com/users/ismaelJimenez/gists{/gist_id}","starred_url":"https://api.github.com/users/ismaelJimenez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ismaelJimenez/subscriptions","organizations_url":"https://api.github.com/users/ismaelJimenez/orgs","repos_url":"https://api.github.com/users/ismaelJimenez/repos","events_url":"https://api.github.com/users/ismaelJimenez/events{/privacy}","received_events_url":"https://api.github.com/users/ismaelJimenez/received_events","type":"User","site_admin":false},"body":"I added the option to report asymptotic complexity and normalized root-mean square error. One of the most important things when implementing a family of benchmarks is not only to see the actual time, but how it relates to the scalability curve. Up until now I had to parse the output of the benchmark with a python script, and calculate the coefficient for the high order term using scipy.optimize.leastsq. With the changes on this check-in, the capability of calculating the high order coefficient and RMS, are built inside the benchmark.\r\n\r\nThe check-in consists basically on the integration of a minimal least squares fitter that I developed as an standalone project and adapted it to work smoothly with the architecture of the benchmark.","created_at":"2016-05-21T14:57:32Z","updated_at":"2016-05-23T18:55:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d46a8a7ddcce98f21be3e6e3826026b613d3aac2","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/google/benchmark/pulls/215/commits","review_comments_url":"https://api.github.com/repos/google/benchmark/pulls/215/comments","review_comment_url":"https://api.github.com/repos/google/benchmark/pulls/comments{/number}","comments_url":"https://api.github.com/repos/google/benchmark/issues/215/comments","statuses_url":"https://api.github.com/repos/google/benchmark/statuses/43ef17441cc8767f5523031878a2f43ab1d7790b","head":{"label":"ismaelJimenez:complexity","ref":"complexity","sha":"43ef17441cc8767f5523031878a2f43ab1d7790b","user":{"login":"ismaelJimenez","id":712805,"avatar_url":"https://avatars.githubusercontent.com/u/712805?v=3","gravatar_id":"","url":"https://api.github.com/users/ismaelJimenez","html_url":"https://github.com/ismaelJimenez","followers_url":"https://api.github.com/users/ismaelJimenez/followers","following_url":"https://api.github.com/users/ismaelJimenez/following{/other_user}","gists_url":"https://api.github.com/users/ismaelJimenez/gists{/gist_id}","starred_url":"https://api.github.com/users/ismaelJimenez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ismaelJimenez/subscriptions","organizations_url":"https://api.github.com/users/ismaelJimenez/orgs","repos_url":"https://api.github.com/users/ismaelJimenez/repos","events_url":"https://api.github.com/users/ismaelJimenez/events{/privacy}","received_events_url":"https://api.github.com/users/ismaelJimenez/received_events","type":"User","site_admin":false},"repo":{"id":59038262,"name":"benchmark","full_name":"ismaelJimenez/benchmark","owner":{"login":"ismaelJimenez","id":712805,"avatar_url":"https://avatars.githubusercontent.com/u/712805?v=3","gravatar_id":"","url":"https://api.github.com/users/ismaelJimenez","html_url":"https://github.com/ismaelJimenez","followers_url":"https://api.github.com/users/ismaelJimenez/followers","following_url":"https://api.github.com/users/ismaelJimenez/following{/other_user}","gists_url":"https://api.github.com/users/ismaelJimenez/gists{/gist_id}","starred_url":"https://api.github.com/users/ismaelJimenez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ismaelJimenez/subscriptions","organizations_url":"https://api.github.com/users/ismaelJimenez/orgs","repos_url":"https://api.github.com/users/ismaelJimenez/repos","events_url":"https://api.github.com/users/ismaelJimenez/events{/privacy}","received_events_url":"https://api.github.com/users/ismaelJimenez/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ismaelJimenez/benchmark","description":"A microbenchmark support library","fork":true,"url":"https://api.github.com/repos/ismaelJimenez/benchmark","forks_url":"https://api.github.com/repos/ismaelJimenez/benchmark/forks","keys_url":"https://api.github.com/repos/ismaelJimenez/benchmark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ismaelJimenez/benchmark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ismaelJimenez/benchmark/teams","hooks_url":"https://api.github.com/repos/ismaelJimenez/benchmark/hooks","issue_events_url":"https://api.github.com/repos/ismaelJimenez/benchmark/issues/events{/number}","events_url":"https://api.github.com/repos/ismaelJimenez/benchmark/events","assignees_url":"https://api.github.com/repos/ismaelJimenez/benchmark/assignees{/user}","branches_url":"https://api.github.com/repos/ismaelJimenez/benchmark/branches{/branch}","tags_url":"https://api.github.com/repos/ismaelJimenez/benchmark/tags","blobs_url":"https://api.github.com/repos/ismaelJimenez/benchmark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ismaelJimenez/benchmark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ismaelJimenez/benchmark/git/refs{/sha}","trees_url":"https://api.github.com/repos/ismaelJimenez/benchmark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ismaelJimenez/benchmark/statuses/{sha}","languages_url":"https://api.github.com/repos/ismaelJimenez/benchmark/languages","stargazers_url":"https://api.github.com/repos/ismaelJimenez/benchmark/stargazers","contributors_url":"https://api.github.com/repos/ismaelJimenez/benchmark/contributors","subscribers_url":"https://api.github.com/repos/ismaelJimenez/benchmark/subscribers","subscription_url":"https://api.github.com/repos/ismaelJimenez/benchmark/subscription","commits_url":"https://api.github.com/repos/ismaelJimenez/benchmark/commits{/sha}","git_commits_url":"https://api.github.com/repos/ismaelJimenez/benchmark/git/commits{/sha}","comments_url":"https://api.github.com/repos/ismaelJimenez/benchmark/comments{/number}","issue_comment_url":"https://api.github.com/repos/ismaelJimenez/benchmark/issues/comments{/number}","contents_url":"https://api.github.com/repos/ismaelJimenez/benchmark/contents/{+path}","compare_url":"https://api.github.com/repos/ismaelJimenez/benchmark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ismaelJimenez/benchmark/merges","archive_url":"https://api.github.com/repos/ismaelJimenez/benchmark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ismaelJimenez/benchmark/downloads","issues_url":"https://api.github.com/repos/ismaelJimenez/benchmark/issues{/number}","pulls_url":"https://api.github.com/repos/ismaelJimenez/benchmark/pulls{/number}","milestones_url":"https://api.github.com/repos/ismaelJimenez/benchmark/milestones{/number}","notifications_url":"https://api.github.com/repos/ismaelJimenez/benchmark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ismaelJimenez/benchmark/labels{/name}","releases_url":"https://api.github.com/repos/ismaelJimenez/benchmark/releases{/id}","deployments_url":"https://api.github.com/repos/ismaelJimenez/benchmark/deployments","created_at":"2016-05-17T16:09:48Z","updated_at":"2016-05-17T16:09:49Z","pushed_at":"2016-05-23T18:50:54Z","git_url":"git://github.com/ismaelJimenez/benchmark.git","ssh_url":"git@github.com:ismaelJimenez/benchmark.git","clone_url":"https://github.com/ismaelJimenez/benchmark.git","svn_url":"https://github.com/ismaelJimenez/benchmark","homepage":"","size":546,"stargazers_count":0,"watchers_count":0,"language":"C++","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":"google:master","ref":"master","sha":"0a60062b3e8ae0376e6fcd41c5da50714a9ef47b","user":{"login":"google","id":1342004,"avatar_url":"https://avatars.githubusercontent.com/u/1342004?v=3","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"repo":{"id":15122806,"name":"benchmark","full_name":"google/benchmark","owner":{"login":"google","id":1342004,"avatar_url":"https://avatars.githubusercontent.com/u/1342004?v=3","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/google/benchmark","description":"A microbenchmark support library","fork":false,"url":"https://api.github.com/repos/google/benchmark","forks_url":"https://api.github.com/repos/google/benchmark/forks","keys_url":"https://api.github.com/repos/google/benchmark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/google/benchmark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/google/benchmark/teams","hooks_url":"https://api.github.com/repos/google/benchmark/hooks","issue_events_url":"https://api.github.com/repos/google/benchmark/issues/events{/number}","events_url":"https://api.github.com/repos/google/benchmark/events","assignees_url":"https://api.github.com/repos/google/benchmark/assignees{/user}","branches_url":"https://api.github.com/repos/google/benchmark/branches{/branch}","tags_url":"https://api.github.com/repos/google/benchmark/tags","blobs_url":"https://api.github.com/repos/google/benchmark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/google/benchmark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/google/benchmark/git/refs{/sha}","trees_url":"https://api.github.com/repos/google/benchmark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/google/benchmark/statuses/{sha}","languages_url":"https://api.github.com/repos/google/benchmark/languages","stargazers_url":"https://api.github.com/repos/google/benchmark/stargazers","contributors_url":"https://api.github.com/repos/google/benchmark/contributors","subscribers_url":"https://api.github.com/repos/google/benchmark/subscribers","subscription_url":"https://api.github.com/repos/google/benchmark/subscription","commits_url":"https://api.github.com/repos/google/benchmark/commits{/sha}","git_commits_url":"https://api.github.com/repos/google/benchmark/git/commits{/sha}","comments_url":"https://api.github.com/repos/google/benchmark/comments{/number}","issue_comment_url":"https://api.github.com/repos/google/benchmark/issues/comments{/number}","contents_url":"https://api.github.com/repos/google/benchmark/contents/{+path}","compare_url":"https://api.github.com/repos/google/benchmark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/google/benchmark/merges","archive_url":"https://api.github.com/repos/google/benchmark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/google/benchmark/downloads","issues_url":"https://api.github.com/repos/google/benchmark/issues{/number}","pulls_url":"https://api.github.com/repos/google/benchmark/pulls{/number}","milestones_url":"https://api.github.com/repos/google/benchmark/milestones{/number}","notifications_url":"https://api.github.com/repos/google/benchmark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/google/benchmark/labels{/name}","releases_url":"https://api.github.com/repos/google/benchmark/releases{/id}","deployments_url":"https://api.github.com/repos/google/benchmark/deployments","created_at":"2013-12-12T00:10:48Z","updated_at":"2016-05-23T15:30:57Z","pushed_at":"2016-05-23T18:50:55Z","git_url":"git://github.com/google/benchmark.git","ssh_url":"git@github.com:google/benchmark.git","clone_url":"https://github.com/google/benchmark.git","svn_url":"https://github.com/google/benchmark","homepage":"","size":1173,"stargazers_count":901,"watchers_count":901,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":158,"mirror_url":null,"open_issues_count":25,"forks":158,"open_issues":25,"watchers":901,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/google/benchmark/pulls/215"},"html":{"href":"https://github.com/google/benchmark/pull/215"},"issue":{"href":"https://api.github.com/repos/google/benchmark/issues/215"},"comments":{"href":"https://api.github.com/repos/google/benchmark/issues/215/comments"},"review_comments":{"href":"https://api.github.com/repos/google/benchmark/pulls/215/comments"},"review_comment":{"href":"https://api.github.com/repos/google/benchmark/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/google/benchmark/pulls/215/commits"},"statuses":{"href":"https://api.github.com/repos/google/benchmark/statuses/43ef17441cc8767f5523031878a2f43ab1d7790b"}}}}
{"actor":{"display_login":"dominichamon"}}