-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#722 Adding Host Name in Reporting #733
Changes from 1 commit
3f44492
f38f8ef
2c6d90c
0ffce1d
8128e07
7147aee
b628cf4
6223a48
a651c6f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,9 @@ void BenchmarkReporter::PrintBasicContext(std::ostream *out, | |
|
||
Out << LocalDateTimeString() << "\n"; | ||
|
||
const SystemInformation &sys_info = context.sys_info; | ||
Out << "System Name "<< sys_info.name << "\n"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this printed only for the json dumper, or for all of them? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed from console and added only to JSON |
||
|
||
if (context.executable_name) | ||
Out << "Running " << context.executable_name << "\n"; | ||
|
||
|
@@ -79,7 +82,7 @@ void BenchmarkReporter::PrintBasicContext(std::ostream *out, | |
// No initializer because it's already initialized to NULL. | ||
const char *BenchmarkReporter::Context::executable_name; | ||
|
||
BenchmarkReporter::Context::Context() : cpu_info(CPUInfo::Get()) {} | ||
BenchmarkReporter::Context::Context() : cpu_info(CPUInfo::Get()), sys_info(SystemInformation::Get()) {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Linewrap |
||
|
||
std::string BenchmarkReporter::Run::benchmark_name() const { | ||
std::string name = run_name; | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -366,6 +366,30 @@ std::vector<CPUInfo::CacheInfo> GetCacheSizes() { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
#endif | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
std::string GetSystemName() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
#if defined(BENCHMARK_OS_WINDOWS) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
std::string str; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const unsigned COUNT = 32767; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, why invent a magic number. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
TCHAR hostname[COUNT]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
DWORD DWCOUNT = COUNT; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (!GetComputerName(hostname, &DWCOUNT)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return std::string("Unable to Get Host Name"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. return empty string and don't print in that case? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we can use something like this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. merging requested changes |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
#ifndef UNICODE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
str = hostname; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you 100.0% sure this is safe?
I'd recommend to use 'returned' There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Initialising TCHAR to null and only copying DWCOUNT into string. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
#else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
std::wstring wStr = hostname; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
str = std::string(wStr.begin(), wStr.end()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this work? Is this already done elsewhere in the library? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using Standard wstring_convert to fix this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, same comment about |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
#endif | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return str; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
#else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const unsigned COUNT = 64; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. HOST_NAME_MAX was not present on OSx, added local initialization. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
char hostname[COUNT]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
int retVal = gethostname(hostname, COUNT); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (retVal != 0) return std::string("Unable to Get Host Name"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return std::string(hostname); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
#endif | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And others? benchmark/src/internal_macros.h Lines 39 to 73 in 439d6b1
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The only segregation needed here is POSIX vs non POSIX Compliance. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
int GetNumCPUs() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
#ifdef BENCHMARK_HAS_SYSCTL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
int NumCPU = -1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -609,4 +633,11 @@ CPUInfo::CPUInfo() | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
scaling_enabled(CpuScalingEnabled(num_cpus)), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
load_avg(GetLoadAvg()) {} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const SystemInformation& SystemInformation::Get() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
static const SystemInformation* info = new SystemInformation(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return *info; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
SystemInformation::SystemInformation() : name(GetSystemName()) {} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} // end namespace benchmark |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ static int AddContextCases() { | |
AddCases(TC_ConsoleErr, | ||
{ | ||
{"%int[-/]%int[-/]%int %int:%int:%int$", MR_Default}, | ||
{"System Name", MR_Next}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is "system name"? |
||
{"Running .*/reporter_output_test(\\.exe)?$", MR_Next}, | ||
{"Run on \\(%int X %float MHz CPU s?\\)", MR_Next}, | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: for consistency with CPUInfo, maybe SystemInfo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be done, let me know if you want me proceed with this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done