{"action":"created","issue":{"url":"https://api.github.com/repos/google/benchmark/issues/259","repository_url":"https://api.github.com/repos/google/benchmark","labels_url":"https://api.github.com/repos/google/benchmark/issues/259/labels{/name}","comments_url":"https://api.github.com/repos/google/benchmark/issues/259/comments","events_url":"https://api.github.com/repos/google/benchmark/issues/259/events","html_url":"https://github.com/google/benchmark/pull/259","id":166754381,"number":259,"title":"Add `RegisterBenchmark(name, func, args...)`  for creating/registering benchmarks.","user":{"login":"EricWF","id":1176427,"avatar_url":"https://avatars.githubusercontent.com/u/1176427?v=3","gravatar_id":"","url":"https://api.github.com/users/EricWF","html_url":"https://github.com/EricWF","followers_url":"https://api.github.com/users/EricWF/followers","following_url":"https://api.github.com/users/EricWF/following{/other_user}","gists_url":"https://api.github.com/users/EricWF/gists{/gist_id}","starred_url":"https://api.github.com/users/EricWF/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/EricWF/subscriptions","organizations_url":"https://api.github.com/users/EricWF/orgs","repos_url":"https://api.github.com/users/EricWF/repos","events_url":"https://api.github.com/users/EricWF/events{/privacy}","received_events_url":"https://api.github.com/users/EricWF/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/google/benchmark/labels/cla:%20yes","name":"cla: yes","color":"009800"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-07-21T07:27:08Z","updated_at":"2016-07-21T07:55:06Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/google/benchmark/pulls/259","html_url":"https://github.com/google/benchmark/pull/259","diff_url":"https://github.com/google/benchmark/pull/259.diff","patch_url":"https://github.com/google/benchmark/pull/259.patch"},"body":"The current method of registering benchmarks can be quite limiting. Currently registration must be done at the global scope during program startup, and each benchmark must be registered separately (on a separate line). For the simple cases this works OK, but quickly gets unwieldy as the number of benchmarks grows.\r\n\r\nThe solution is simple. We should allow benchmarks to be created and registered at a local (non-global) scope.  This patch adds `RegisterBenchmark(name, func, args...)` , which can be used to create and register benchmarks anywhere at any time and with any arguments. This is infinity more flexible than the current API.\r\n\r\nThe signature of `RegisterBenchmarks` is:\r\n\r\n```c++\r\ntemplate <class Functor, class ...Args>\r\ninternal::Benchmark* RegisterBenchmark(const char* name, Functor&& fn, Args&&... args);\r\n```\r\nThe function creates a new benchmark with the specified `name`, registers it, and returns a non-owning pointer to it. When the benchmark is run it will invoke `fn(st, args...)` where `st` is the `State` object. \r\n\r\nExample Usage:\r\n\r\n```c++\r\nauto BM_test = [](benchmark::State& st, auto Inputs) { /* ... */ };\r\n\r\nint main(int argc, char** argv) {\r\n  for (auto& test_input : { /* ... */ })\r\n      benchmark::RegisterBenchmark(test_input.name(), BM_test, test_input);\r\n  benchmark::Initialize(&argc, argv);\r\n  benchmark::RunSpecifiedBenchmarks();\r\n}\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/google/benchmark/issues/comments/234182861","html_url":"https://github.com/google/benchmark/pull/259#issuecomment-234182861","issue_url":"https://api.github.com/repos/google/benchmark/issues/259","id":234182861,"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},"created_at":"2016-07-21T07:55:06Z","updated_at":"2016-07-21T07:55:06Z","body":"no matter how long it has been, we have users who do not have C++11 support. dropping them would be unfortunate.\r\n\r\nhaving said that, if we state that as of version X we are only supporting C++11, that just leaves them on an old (working) version. What do you think?"}}
{"actor":{"display_login":"dominichamon"}}