mirror of https://github.com/google/benchmark.git
* [FR] Provide public accessors to benchmark name and arguments #1551 * Update AUTHORS and CONTRIBUTORS * Update benchmark_register.cc * Fix lint formatting
This commit is contained in:
parent
060d762d61
commit
f32748c372
1
AUTHORS
1
AUTHORS
|
@ -46,6 +46,7 @@ Lei Xu <eddyxu@gmail.com>
|
|||
Marcel Jacobse <mjacobse@uni-bremen.de>
|
||||
Matt Clarkson <mattyclarkson@gmail.com>
|
||||
Maxim Vafin <maxvafin@gmail.com>
|
||||
Mike Apodaca <gatorfax@gmail.com>
|
||||
MongoDB Inc.
|
||||
Nick Hutchinson <nshutchinson@gmail.com>
|
||||
Norman Heino <norman.heino@gmail.com>
|
||||
|
|
|
@ -67,6 +67,7 @@ Lei Xu <eddyxu@gmail.com>
|
|||
Marcel Jacobse <mjacobse@uni-bremen.de>
|
||||
Matt Clarkson <mattyclarkson@gmail.com>
|
||||
Maxim Vafin <maxvafin@gmail.com>
|
||||
Mike Apodaca <gatorfax@gmail.com>
|
||||
Nick Hutchinson <nshutchinson@gmail.com>
|
||||
Norman Heino <norman.heino@gmail.com>
|
||||
Oleksandr Sochka <sasha.sochka@gmail.com>
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<int>(args_.front().size());
|
||||
}
|
||||
|
||||
const char* Benchmark::GetArgName(int arg) const {
|
||||
BM_CHECK_GE(arg, 0);
|
||||
BM_CHECK_LT(arg, static_cast<int>(arg_names_.size()));
|
||||
return arg_names_[arg].c_str();
|
||||
}
|
||||
|
||||
TimeUnit Benchmark::GetTimeUnit() const {
|
||||
return use_default_time_unit_ ? GetDefaultTimeUnit() : time_unit_;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue