@@ -366,6 +366,33 @@ std::vector<CPUInfo::CacheInfo> GetCacheSizes() {
366
366
#endif
367
367
}
368
368
369
+ std::string GetSystemName () {
370
+ #if defined(BENCHMARK_OS_WINDOWS)
371
+ std::string str;
372
+ const unsigned COUNT = MAX_COMPUTERNAME_LENGTH+1 ;
373
+ TCHAR hostname[COUNT];
374
+ DWORD DWCOUNT = COUNT;
375
+ if (!GetComputerName (hostname, &DWCOUNT))
376
+ return std::string (" Unable to Get Host Name" );
377
+ #ifndef UNICODE
378
+ str = hostname;
379
+ #else
380
+ std::wstring wStr = hostname;
381
+ str = std::string (wStr.begin (), wStr.end ());
382
+ #endif
383
+ return str;
384
+ #else
385
+ #ifdef BENCHMARK_OS_MACOSX // Mac Doesnt have a copy for Host Name in it
386
+ #define HOST_NAME_MAX 64
387
+ #endif
388
+ const unsigned COUNT = HOST_NAME_MAX;
389
+ char hostname[COUNT];
390
+ int retVal = gethostname (hostname, COUNT);
391
+ if (retVal != 0 ) return std::string (" Unable to Get Host Name" );
392
+ return std::string (hostname);
393
+ #endif
394
+ }
395
+
369
396
int GetNumCPUs () {
370
397
#ifdef BENCHMARK_HAS_SYSCTL
371
398
int NumCPU = -1 ;
@@ -609,4 +636,11 @@ CPUInfo::CPUInfo()
609
636
scaling_enabled(CpuScalingEnabled(num_cpus)),
610
637
load_avg(GetLoadAvg()) {}
611
638
639
+
640
+ const SystemInformation& SystemInformation::Get () {
641
+ static const SystemInformation* info = new SystemInformation ();
642
+ return *info;
643
+ }
644
+
645
+ SystemInformation::SystemInformation () : name(GetSystemName()) {}
612
646
} // end namespace benchmark
0 commit comments