diff --git a/AUTHORS b/AUTHORS index b7b3b2e4..bafecadd 100644 --- a/AUTHORS +++ b/AUTHORS @@ -46,6 +46,7 @@ Lei Xu Marcel Jacobse Matt Clarkson Maxim Vafin +Mike Apodaca MongoDB Inc. Nick Hutchinson Norman Heino diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 37b000a1..56f03e2d 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -67,6 +67,7 @@ Lei Xu Marcel Jacobse Matt Clarkson Maxim Vafin +Mike Apodaca Nick Hutchinson Norman Heino Oleksandr Sochka diff --git a/include/benchmark/benchmark.h b/include/benchmark/benchmark.h index 783fcd8e..3e7e1dc5 100644 --- a/include/benchmark/benchmark.h +++ b/include/benchmark/benchmark.h @@ -1245,7 +1245,10 @@ class BENCHMARK_EXPORT Benchmark { explicit Benchmark(const char* name); void SetName(const char* name); + public: + const char* GetName() const; int ArgsCnt() const; + const char* GetArgName(int arg) const; private: friend class BenchmarkFamilies; diff --git a/src/benchmark_register.cc b/src/benchmark_register.cc index eae2c320..4503dd1d 100644 --- a/src/benchmark_register.cc +++ b/src/benchmark_register.cc @@ -470,6 +470,8 @@ Benchmark* Benchmark::ThreadPerCpu() { void Benchmark::SetName(const char* name) { name_ = name; } +const char* Benchmark::GetName() const { return name_.c_str(); } + int Benchmark::ArgsCnt() const { if (args_.empty()) { if (arg_names_.empty()) return -1; @@ -478,6 +480,12 @@ int Benchmark::ArgsCnt() const { return static_cast(args_.front().size()); } +const char* Benchmark::GetArgName(int arg) const { + BM_CHECK_GE(arg, 0); + BM_CHECK_LT(arg, static_cast(arg_names_.size())); + return arg_names_[arg].c_str(); +} + TimeUnit Benchmark::GetTimeUnit() const { return use_default_time_unit_ ? GetDefaultTimeUnit() : time_unit_; }