Skip to content

Commit

Permalink
Changing name SystemInfo and adding empty message incase host name fe…
Browse files Browse the repository at this point in the history
…tch fails
  • Loading branch information
jatinx committed Dec 10, 2018
1 parent b628cf4 commit 6223a48
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions include/benchmark/benchmark.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/reporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions src/sysinfo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
}
Expand Down Expand Up @@ -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

0 comments on commit 6223a48

Please # to comment.