From 6223a48be39d4dfabfa63ab91e832463bb19f45f Mon Sep 17 00:00:00 2001 From: Jatin Chaudhary Date: Mon, 10 Dec 2018 21:29:33 +0530 Subject: [PATCH] Changing name SystemInfo and adding empty message incase host name fetch fails --- include/benchmark/benchmark.h | 10 +++++----- src/reporter.cc | 2 +- src/sysinfo.cc | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/include/benchmark/benchmark.h b/include/benchmark/benchmark.h index fbd1ebc1e7..549efbc29b 100644 --- a/include/benchmark/benchmark.h +++ b/include/benchmark/benchmark.h @@ -1293,12 +1293,12 @@ struct CPUInfo { BENCHMARK_DISALLOW_COPY_AND_ASSIGN(CPUInfo); }; -struct SystemInformation { +struct SystemInfo { std::string name; - static const SystemInformation& Get(); + static const SystemInfo& Get(); private: - SystemInformation(); - BENCHMARK_DISALLOW_COPY_AND_ASSIGN(SystemInformation); + SystemInfo(); + BENCHMARK_DISALLOW_COPY_AND_ASSIGN(SystemInfo); }; // Interface for custom benchmark result printers. @@ -1310,7 +1310,7 @@ class BenchmarkReporter { public: struct Context { CPUInfo const& cpu_info; - SystemInformation const& sys_info; + SystemInfo const& sys_info; // The number of chars in the longest benchmark name. size_t name_field_width; static const char* executable_name; diff --git a/src/reporter.cc b/src/reporter.cc index 45cffe58eb..59bc5f7102 100644 --- a/src/reporter.cc +++ b/src/reporter.cc @@ -80,7 +80,7 @@ void BenchmarkReporter::PrintBasicContext(std::ostream *out, const char *BenchmarkReporter::Context::executable_name; BenchmarkReporter::Context::Context() - : cpu_info(CPUInfo::Get()), sys_info(SystemInformation::Get()) {} + : cpu_info(CPUInfo::Get()), sys_info(SystemInfo::Get()) {} std::string BenchmarkReporter::Run::benchmark_name() const { std::string name = run_name; diff --git a/src/sysinfo.cc b/src/sysinfo.cc index 2a2d4694d5..c0c07e5e62 100644 --- a/src/sysinfo.cc +++ b/src/sysinfo.cc @@ -375,7 +375,7 @@ std::string GetSystemName() { TCHAR hostname[COUNT] = {'\0'}; DWORD DWCOUNT = COUNT; if (!GetComputerName(hostname, &DWCOUNT)) - return std::string("Unable to Get Host Name"); + return std::string(""); #ifndef UNICODE str = std::string(hostname, DWCOUNT); #else @@ -392,7 +392,7 @@ std::string GetSystemName() { #endif char hostname[HOST_NAME_MAX]; int retVal = gethostname(hostname, HOST_NAME_MAX); - if (retVal != 0) return std::string("Unable to Get Host Name"); + if (retVal != 0) return std::string(""); return std::string(hostname); #endif // Catch-all POSIX block. } @@ -641,10 +641,10 @@ CPUInfo::CPUInfo() load_avg(GetLoadAvg()) {} -const SystemInformation& SystemInformation::Get() { - static const SystemInformation* info = new SystemInformation(); +const SystemInfo& SystemInfo::Get() { + static const SystemInfo* info = new SystemInfo(); return *info; } -SystemInformation::SystemInformation() : name(GetSystemName()) {} +SystemInfo::SystemInfo() : name(GetSystemName()) {} } // end namespace benchmark