Skip to content

Conversation

jatinx
Copy link
Contributor

@jatinx jatinx commented Nov 29, 2018

PR with CLA signed

src/reporter.cc Outdated
const char *BenchmarkReporter::Context::executable_name;

BenchmarkReporter::Context::Context() : cpu_info(CPUInfo::Get()) {}
BenchmarkReporter::Context::Context() : cpu_info(CPUInfo::Get()), sys_info(SystemInformation::Get()) {}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linewrap

src/reporter.cc Outdated
Out << LocalDateTimeString() << "\n";

const SystemInformation &sys_info = context.sys_info;
Out << "System Name "<< sys_info.name << "\n";
Copy link
Collaborator

Choose a reason for hiding this comment

The 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?
Put differently, i don't think it should be in the console output, it is getting rather crowded already.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed from console and added only to JSON

src/sysinfo.cc Outdated
#endif
return str;
#else
const unsigned COUNT = 64;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just use HOST_NAME_MAX

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HOST_NAME_MAX was not present on OSx, added local initialization.
The Job on Travis failed in config, can you please have a look at it?

src/sysinfo.cc Outdated
std::string GetSystemName() {
#if defined(BENCHMARK_OS_WINDOWS)
std::string str;
const unsigned COUNT = 32767;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, why invent a magic number.
MAX_COMPUTERNAME_LENGTH+1 ?
And that being said, isn't that a rather too big to have as an array on stack?
Maybe use resized std::string?

AddCases(TC_ConsoleErr,
{
{"%int[-/]%int[-/]%int %int:%int:%int$", MR_Default},
{"System Name", MR_Next},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is "system name"?
How is this different from "host name"?
If it is exactly the "host name", just use that term?

@coveralls
Copy link

coveralls commented Nov 29, 2018

Coverage Status

Coverage increased (+0.06%) to 89.352% when pulling a651c6f on jatinx:HostName into eee8b05 on google:master.

@AppVeyorBot
Copy link

Build benchmark 1584 failed (commit f70f5b39af by @jatinx)

@AppVeyorBot
Copy link

Build benchmark 1585 failed (commit 7f7bb81561 by @jatinx)

@AppVeyorBot
Copy link

Build benchmark 1586 completed (commit 7e957a81be by @jatinx)

@AppVeyorBot
Copy link

Build benchmark 1587 completed (commit ffd0fa611f by @jatinx)

@AppVeyorBot
Copy link

Build benchmark 1589 completed (commit 7fda14a749 by @jatinx)

@jatinx
Copy link
Contributor Author

jatinx commented Nov 30, 2018

@LebedevRI did the asked changes, can you please have a look at it?

@jatinx
Copy link
Contributor Author

jatinx commented Dec 7, 2018

@LebedevRI its been a week, is something wrong with my design, would like some comments if thats the case.

Copy link
Collaborator

@LebedevRI LebedevRI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, lost track.

src/sysinfo.cc Outdated
str = hostname;
#else
std::wstring wStr = hostname;
str = std::string(wStr.begin(), wStr.end());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work? Is this already done elsewhere in the library?
wchar is bigger than char, what makes sure that this isn't lossy?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using Standard wstring_convert to fix this

src/sysinfo.cc Outdated
#ifdef BENCHMARK_OS_MACOSX //Mac Doesnt have a copy for Host Name in it
#define HOST_NAME_MAX 64
#endif
const unsigned COUNT = HOST_NAME_MAX;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't you just use HOST_NAME_MAX directly, why do you need COUNT variable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing unnecessary COUNT variable references, using macro directly

src/sysinfo.cc Outdated
int retVal = gethostname(hostname, COUNT);
if (retVal != 0) return std::string("Unable to Get Host Name");
return std::string(hostname);
#endif
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And others?

#if defined(__CYGWIN__)
#define BENCHMARK_OS_CYGWIN 1
#elif defined(_WIN32)
#define BENCHMARK_OS_WINDOWS 1
#if defined(__MINGW32__)
#define BENCHMARK_OS_MINGW 1
#endif
#elif defined(__APPLE__)
#define BENCHMARK_OS_APPLE 1
#include "TargetConditionals.h"
#if defined(TARGET_OS_MAC)
#define BENCHMARK_OS_MACOSX 1
#if defined(TARGET_OS_IPHONE)
#define BENCHMARK_OS_IOS 1
#endif
#endif
#elif defined(__FreeBSD__)
#define BENCHMARK_OS_FREEBSD 1
#elif defined(__NetBSD__)
#define BENCHMARK_OS_NETBSD 1
#elif defined(__OpenBSD__)
#define BENCHMARK_OS_OPENBSD 1
#elif defined(__linux__)
#define BENCHMARK_OS_LINUX 1
#elif defined(__native_client__)
#define BENCHMARK_OS_NACL 1
#elif defined(__EMSCRIPTEN__)
#define BENCHMARK_OS_EMSCRIPTEN 1
#elif defined(__rtems__)
#define BENCHMARK_OS_RTEMS 1
#elif defined(__Fuchsia__)
#define BENCHMARK_OS_FUCHSIA 1
#elif defined (__SVR4) && defined (__sun)
#define BENCHMARK_OS_SOLARIS 1
#endif