Merge pull request 'SystemInfo caching' (#178) from sysinfo_caching into master
Reviewed-on: https://git.madvoxel.net/OpenVulkano/OpenVulkano/pulls/178 Reviewed-by: Georg Hagen <georg.hagen@madvoxel.com>
This commit is contained in:
@@ -73,7 +73,8 @@ namespace OpenVulkano
|
|||||||
|
|
||||||
size_t SystemInfo::GetSystemRam()
|
size_t SystemInfo::GetSystemRam()
|
||||||
{
|
{
|
||||||
return ReadMemInfo("MemTotal");
|
static const size_t ram = ReadMemInfo("MemTotal");
|
||||||
|
return ram;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t SystemInfo::GetSystemRamAvailable()
|
size_t SystemInfo::GetSystemRamAvailable()
|
||||||
@@ -97,28 +98,48 @@ namespace OpenVulkano
|
|||||||
}
|
}
|
||||||
|
|
||||||
size_t SystemInfo::GetAppVirtualMemoryMax()
|
size_t SystemInfo::GetAppVirtualMemoryMax()
|
||||||
|
{
|
||||||
|
static size_t vramMax;
|
||||||
|
if (vramMax == 0)
|
||||||
{
|
{
|
||||||
rlimit limit;
|
rlimit limit;
|
||||||
if (getrlimit(RLIMIT_AS, &limit) == 0)
|
if (getrlimit(RLIMIT_AS, &limit) == 0)
|
||||||
{
|
{
|
||||||
return limit.rlim_cur;
|
vramMax = limit.rlim_cur;
|
||||||
}
|
}
|
||||||
Logger::PERF->error("Failed to query max application memory");
|
Logger::PERF->error("Failed to query max application memory");
|
||||||
return 0;
|
}
|
||||||
|
return vramMax;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string SystemInfo::GetUserName()
|
std::string SystemInfo::GetUserName()
|
||||||
|
{
|
||||||
|
static std::string userName;
|
||||||
|
if (userName.empty())
|
||||||
{
|
{
|
||||||
char* name = getlogin();
|
char* name = getlogin();
|
||||||
if (!name) return "unknown";
|
if (!name)
|
||||||
return name;
|
{
|
||||||
|
userName = "unknown";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
userName = name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return userName;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string SystemInfo::GetHostName()
|
std::string SystemInfo::GetHostName()
|
||||||
|
{
|
||||||
|
static std::string hostName;
|
||||||
|
if (hostName.empty())
|
||||||
{
|
{
|
||||||
char hostname[HOST_NAME_MAX + 1];
|
char hostname[HOST_NAME_MAX + 1];
|
||||||
gethostname(hostname, HOST_NAME_MAX + 1);
|
gethostname(hostname, HOST_NAME_MAX + 1);
|
||||||
return hostname;
|
hostName = hostname;
|
||||||
|
}
|
||||||
|
return hostName;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string SystemInfo::GetDeviceName()
|
std::string SystemInfo::GetDeviceName()
|
||||||
@@ -127,31 +148,45 @@ namespace OpenVulkano
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string SystemInfo::GetDeviceVendorName()
|
std::string SystemInfo::GetDeviceVendorName()
|
||||||
|
{
|
||||||
|
static std::string vendor;
|
||||||
|
if (vendor.empty())
|
||||||
{
|
{
|
||||||
std::ifstream dmiStream("/sys/class/dmi/id/board_vendor");
|
std::ifstream dmiStream("/sys/class/dmi/id/board_vendor");
|
||||||
if (!dmiStream)
|
if (!dmiStream)
|
||||||
{
|
{
|
||||||
Logger::PERF->error("Failed to read /sys/class/dmi/id/board_vendor");
|
Logger::PERF->error("Failed to read /sys/class/dmi/id/board_vendor");
|
||||||
return "Unknown";
|
vendor = "Unknown";
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
std::string motherboardName;
|
std::string motherboardName;
|
||||||
std::getline(dmiStream, motherboardName);
|
std::getline(dmiStream, motherboardName);
|
||||||
return motherboardName;
|
vendor = motherboardName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return vendor;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string SystemInfo::GetDeviceModelName()
|
std::string SystemInfo::GetDeviceModelName()
|
||||||
|
{
|
||||||
|
static std::string modelName;
|
||||||
|
if (modelName.empty())
|
||||||
{
|
{
|
||||||
std::ifstream dmiStream("/sys/class/dmi/id/board_name");
|
std::ifstream dmiStream("/sys/class/dmi/id/board_name");
|
||||||
if (!dmiStream)
|
if (!dmiStream)
|
||||||
{
|
{
|
||||||
Logger::PERF->error("Failed to read /sys/class/dmi/id/board_name");
|
Logger::PERF->error("Failed to read /sys/class/dmi/id/board_name");
|
||||||
return "Unknown";
|
modelName = "Unknown";
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
std::string motherboardName;
|
std::string motherboardName;
|
||||||
std::getline(dmiStream, motherboardName);
|
std::getline(dmiStream, motherboardName);
|
||||||
return motherboardName;
|
modelName = motherboardName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return modelName;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
@@ -275,7 +310,8 @@ namespace OpenVulkano
|
|||||||
|
|
||||||
size_t SystemInfo::GetCpuThreadCount()
|
size_t SystemInfo::GetCpuThreadCount()
|
||||||
{
|
{
|
||||||
return std::thread::hardware_concurrency();
|
static const size_t threadCount = std::thread::hardware_concurrency();
|
||||||
|
return threadCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t SystemInfo::GetCpuTemperature()
|
int32_t SystemInfo::GetCpuTemperature()
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include "Host/SystemInfo.hpp"
|
#include "Host/SystemInfo.hpp"
|
||||||
#include "Base/Logger.hpp"
|
#include "Base/Logger.hpp"
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <fmt/core.h>
|
||||||
|
|
||||||
#include <mach/mach.h>
|
#include <mach/mach.h>
|
||||||
#include <os/proc.h>
|
#include <os/proc.h>
|
||||||
@@ -24,7 +25,8 @@ namespace OpenVulkano
|
|||||||
|
|
||||||
size_t SystemInfo::GetSystemRam()
|
size_t SystemInfo::GetSystemRam()
|
||||||
{
|
{
|
||||||
return [NSProcessInfo processInfo].physicalMemory;
|
static const size_t ram = [NSProcessInfo processInfo].physicalMemory;
|
||||||
|
return ram;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t SystemInfo::GetSystemRamAvailable()
|
size_t SystemInfo::GetSystemRamAvailable()
|
||||||
@@ -67,12 +69,14 @@ namespace OpenVulkano
|
|||||||
|
|
||||||
std::string SystemInfo::GetHostName()
|
std::string SystemInfo::GetHostName()
|
||||||
{
|
{
|
||||||
return [[NSProcessInfo processInfo].hostName UTF8String];
|
static const std::string hostName = [[NSProcessInfo processInfo].hostName UTF8String];
|
||||||
|
return hostName;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string SystemInfo::GetDeviceName()
|
std::string SystemInfo::GetDeviceName()
|
||||||
{
|
{
|
||||||
return "Mac"; //TODO
|
static const std::string devName = "Mac"; //TODO
|
||||||
|
return devName;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string SystemInfo::GetDeviceVendorName()
|
std::string SystemInfo::GetDeviceVendorName()
|
||||||
@@ -81,10 +85,15 @@ namespace OpenVulkano
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string SystemInfo::GetDeviceModelName()
|
std::string SystemInfo::GetDeviceModelName()
|
||||||
|
{
|
||||||
|
static std::string machine;
|
||||||
|
if (machine.empty())
|
||||||
{
|
{
|
||||||
struct utsname systemInfo;
|
struct utsname systemInfo;
|
||||||
uname(&systemInfo);
|
uname(&systemInfo);
|
||||||
return systemInfo.machine;
|
machine = systemInfo.machine;
|
||||||
|
}
|
||||||
|
return machine;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string SystemInfo::GetOsName()
|
std::string SystemInfo::GetOsName()
|
||||||
@@ -94,15 +103,20 @@ namespace OpenVulkano
|
|||||||
|
|
||||||
OsVersion SystemInfo::GetOsVersion()
|
OsVersion SystemInfo::GetOsVersion()
|
||||||
{
|
{
|
||||||
NSOperatingSystemVersion osVersion = [NSProcessInfo processInfo].operatingSystemVersion;
|
static OsVersion osVersion = {};
|
||||||
return { static_cast<int>(osVersion.majorVersion), static_cast<int>(osVersion.minorVersion), static_cast<int>(osVersion.patchVersion), 0 };
|
if (osVersion.major == 0 && osVersion.minor == 0)
|
||||||
|
{
|
||||||
|
NSOperatingSystemVersion sysVersion = [NSProcessInfo processInfo].operatingSystemVersion;
|
||||||
|
osVersion = { static_cast<int>(sysVersion.majorVersion), static_cast<int>(sysVersion.minorVersion),
|
||||||
|
static_cast<int>(sysVersion.patchVersion), 0 };
|
||||||
|
}
|
||||||
|
return osVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string SystemInfo::GetOsNameHumanReadable()
|
std::string SystemInfo::GetOsNameHumanReadable()
|
||||||
{
|
{
|
||||||
std::stringstream name;
|
static const std::string hrName = fmt::format("{} {}", GetOsName(), GetOsVersion().major);
|
||||||
name << GetOsName() << ' ' << GetOsVersion().major;
|
return hrName;
|
||||||
return name.str();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceType SystemInfo::GetDeviceType()
|
DeviceType SystemInfo::GetDeviceType()
|
||||||
@@ -112,12 +126,14 @@ namespace OpenVulkano
|
|||||||
|
|
||||||
size_t SystemInfo::GetCpuCoreCount()
|
size_t SystemInfo::GetCpuCoreCount()
|
||||||
{
|
{
|
||||||
return [NSProcessInfo processInfo].processorCount;
|
static const size_t coreCount = [NSProcessInfo processInfo].processorCount;
|
||||||
|
return coreCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t SystemInfo::GetCpuThreadCount()
|
size_t SystemInfo::GetCpuThreadCount()
|
||||||
{
|
{
|
||||||
return [NSProcessInfo processInfo].activeProcessorCount;
|
static size_t procCount = [NSProcessInfo processInfo].activeProcessorCount;
|
||||||
|
return procCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t SystemInfo::GetCpuTemperature()
|
int32_t SystemInfo::GetCpuTemperature()
|
||||||
|
|||||||
@@ -253,89 +253,7 @@ namespace OpenVulkano
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
std::string GetHumanReadableOSName()
|
||||||
|
|
||||||
size_t SystemInfo::GetSystemRam()
|
|
||||||
{
|
|
||||||
return ReadSystemMemInfo(SYS_MEM_TYPE::TOTAL_PHYS);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t SystemInfo::GetSystemRamAvailable()
|
|
||||||
{
|
|
||||||
return ReadSystemMemInfo(SYS_MEM_TYPE::AVAIL_PHYS);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t SystemInfo::GetAppRamMax()
|
|
||||||
{
|
|
||||||
return std::min(GetSystemRam(), GetCommitLimit());
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t SystemInfo::GetAppRamAvailable()
|
|
||||||
{
|
|
||||||
return std::min(GetSystemRamAvailable(), GetCommitLimit() - GetAppRamUsed());
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t SystemInfo::GetAppRamUsed()
|
|
||||||
{
|
|
||||||
return ReadAppMemInfo(APP_MEM_TYPE::USED);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t SystemInfo::GetAppVirtualMemoryMax()
|
|
||||||
{
|
|
||||||
return ReadAppMemInfo(APP_MEM_TYPE::VM_MAX);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string SystemInfo::GetUserName()
|
|
||||||
{
|
|
||||||
char username[UNLEN+1];
|
|
||||||
DWORD username_len = UNLEN+1;
|
|
||||||
::GetUserNameA(username, &username_len);
|
|
||||||
return username;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string SystemInfo::GetHostName()
|
|
||||||
{
|
|
||||||
char hostname[UNLEN+1];
|
|
||||||
gethostname(hostname, UNLEN+1);
|
|
||||||
return hostname;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string SystemInfo::GetDeviceName()
|
|
||||||
{
|
|
||||||
char computerName[UNLEN+1];
|
|
||||||
DWORD computerName_len = UNLEN+1;
|
|
||||||
GetComputerNameA(computerName, &computerName_len);
|
|
||||||
return computerName;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string SystemInfo::GetDeviceVendorName()
|
|
||||||
{
|
|
||||||
std::optional<std::string> res = GetWMIProperty("Manufacturer");
|
|
||||||
return res ? *res : "Unknown";
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string SystemInfo::GetDeviceModelName()
|
|
||||||
{
|
|
||||||
std::optional<std::string> res = GetWMIProperty("Model");
|
|
||||||
return res ? *res : "Unknown";
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string SystemInfo::GetOsName()
|
|
||||||
{
|
|
||||||
return "Windows";
|
|
||||||
}
|
|
||||||
|
|
||||||
OsVersion SystemInfo::GetOsVersion()
|
|
||||||
{
|
|
||||||
NTSTATUS(WINAPI * RtlGetVersion)(LPOSVERSIONINFOEXW);
|
|
||||||
OSVERSIONINFOEXW info;
|
|
||||||
*(FARPROC*) &RtlGetVersion = GetProcAddress(GetModuleHandleA("ntdll"), "RtlGetVersion");
|
|
||||||
info.dwOSVersionInfoSize = sizeof(info);
|
|
||||||
RtlGetVersion(&info);
|
|
||||||
return { (int)info.dwMajorVersion, (int)info.dwMinorVersion, 0, (int)info.dwBuildNumber };
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string SystemInfo::GetOsNameHumanReadable()
|
|
||||||
{
|
{
|
||||||
NTSTATUS(WINAPI *RtlGetVersion)(LPOSVERSIONINFOEXW);
|
NTSTATUS(WINAPI *RtlGetVersion)(LPOSVERSIONINFOEXW);
|
||||||
OSVERSIONINFOEXW info;
|
OSVERSIONINFOEXW info;
|
||||||
@@ -409,6 +327,123 @@ namespace OpenVulkano
|
|||||||
return "Windows Server " + std::to_string(info.dwMajorVersion) + "." + std::to_string(info.dwMinorVersion);
|
return "Windows Server " + std::to_string(info.dwMajorVersion) + "." + std::to_string(info.dwMinorVersion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t SystemInfo::GetSystemRam()
|
||||||
|
{
|
||||||
|
return ReadSystemMemInfo(SYS_MEM_TYPE::TOTAL_PHYS);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t SystemInfo::GetSystemRamAvailable()
|
||||||
|
{
|
||||||
|
return ReadSystemMemInfo(SYS_MEM_TYPE::AVAIL_PHYS);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t SystemInfo::GetAppRamMax()
|
||||||
|
{
|
||||||
|
return std::min(GetSystemRam(), GetCommitLimit());
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t SystemInfo::GetAppRamAvailable()
|
||||||
|
{
|
||||||
|
return std::min(GetSystemRamAvailable(), GetCommitLimit() - GetAppRamUsed());
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t SystemInfo::GetAppRamUsed()
|
||||||
|
{
|
||||||
|
return ReadAppMemInfo(APP_MEM_TYPE::USED);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t SystemInfo::GetAppVirtualMemoryMax()
|
||||||
|
{
|
||||||
|
return ReadAppMemInfo(APP_MEM_TYPE::VM_MAX);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string SystemInfo::GetUserName()
|
||||||
|
{
|
||||||
|
static std::string userName;
|
||||||
|
if (userName.empty())
|
||||||
|
{
|
||||||
|
char username[UNLEN + 1];
|
||||||
|
DWORD username_len = UNLEN + 1;
|
||||||
|
::GetUserNameA(username, &username_len);
|
||||||
|
userName = username;
|
||||||
|
}
|
||||||
|
return userName;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string SystemInfo::GetHostName()
|
||||||
|
{
|
||||||
|
static std::string hostName;
|
||||||
|
if (hostName.empty())
|
||||||
|
{
|
||||||
|
char hostname[UNLEN+1];
|
||||||
|
gethostname(hostname, UNLEN+1);
|
||||||
|
hostName = hostname;
|
||||||
|
}
|
||||||
|
return hostName;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string SystemInfo::GetDeviceName()
|
||||||
|
{
|
||||||
|
static std::string devName;
|
||||||
|
if (devName.empty())
|
||||||
|
{
|
||||||
|
char computerName[UNLEN+1];
|
||||||
|
DWORD computerName_len = UNLEN+1;
|
||||||
|
GetComputerNameA(computerName, &computerName_len);
|
||||||
|
devName = computerName;
|
||||||
|
}
|
||||||
|
return devName;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string SystemInfo::GetDeviceVendorName()
|
||||||
|
{
|
||||||
|
static std::string vendorName;
|
||||||
|
if (vendorName.empty())
|
||||||
|
{
|
||||||
|
std::optional<std::string> res = GetWMIProperty("Manufacturer");
|
||||||
|
vendorName = res ? *res : "Unknown";
|
||||||
|
}
|
||||||
|
return vendorName;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string SystemInfo::GetDeviceModelName()
|
||||||
|
{
|
||||||
|
static std::string deviceModelName;
|
||||||
|
if (deviceModelName.empty())
|
||||||
|
{
|
||||||
|
std::optional<std::string> res = GetWMIProperty("Model");
|
||||||
|
deviceModelName = res ? *res : "Unknown";
|
||||||
|
}
|
||||||
|
return deviceModelName;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string SystemInfo::GetOsName()
|
||||||
|
{
|
||||||
|
return "Windows";
|
||||||
|
}
|
||||||
|
|
||||||
|
OsVersion SystemInfo::GetOsVersion()
|
||||||
|
{
|
||||||
|
static OsVersion osVersion = {};
|
||||||
|
if (osVersion.major == 0 && osVersion.minor == 0)
|
||||||
|
{
|
||||||
|
NTSTATUS(WINAPI * RtlGetVersion)(LPOSVERSIONINFOEXW);
|
||||||
|
OSVERSIONINFOEXW info;
|
||||||
|
*(FARPROC*) &RtlGetVersion = GetProcAddress(GetModuleHandleA("ntdll"), "RtlGetVersion");
|
||||||
|
info.dwOSVersionInfoSize = sizeof(info);
|
||||||
|
RtlGetVersion(&info);
|
||||||
|
osVersion = { (int)info.dwMajorVersion, (int)info.dwMinorVersion, 0, (int)info.dwBuildNumber };
|
||||||
|
}
|
||||||
|
return osVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string SystemInfo::GetOsNameHumanReadable()
|
||||||
|
{
|
||||||
|
static const std::string osName = GetHumanReadableOSName();
|
||||||
|
return osName;
|
||||||
|
}
|
||||||
|
|
||||||
DeviceType SystemInfo::GetDeviceType()
|
DeviceType SystemInfo::GetDeviceType()
|
||||||
{
|
{
|
||||||
@@ -416,6 +451,9 @@ namespace OpenVulkano
|
|||||||
}
|
}
|
||||||
|
|
||||||
size_t SystemInfo::GetCpuCoreCount()
|
size_t SystemInfo::GetCpuCoreCount()
|
||||||
|
{
|
||||||
|
static size_t coreCount = 0;
|
||||||
|
if (coreCount == 0)
|
||||||
{
|
{
|
||||||
DWORD bufferSize = 0;
|
DWORD bufferSize = 0;
|
||||||
GetLogicalProcessorInformationEx(LOGICAL_PROCESSOR_RELATIONSHIP::RelationProcessorCore, nullptr, &bufferSize);
|
GetLogicalProcessorInformationEx(LOGICAL_PROCESSOR_RELATIONSHIP::RelationProcessorCore, nullptr, &bufferSize);
|
||||||
@@ -433,7 +471,9 @@ namespace OpenVulkano
|
|||||||
physProcessorCount++;
|
physProcessorCount++;
|
||||||
start += current->Size;
|
start += current->Size;
|
||||||
}
|
}
|
||||||
return physProcessorCount;
|
coreCount = physProcessorCount;
|
||||||
|
}
|
||||||
|
return coreCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t SystemInfo::GetCpuThreadCount()
|
size_t SystemInfo::GetCpuThreadCount()
|
||||||
|
|||||||
@@ -27,7 +27,8 @@ namespace OpenVulkano
|
|||||||
|
|
||||||
size_t SystemInfo::GetSystemRam()
|
size_t SystemInfo::GetSystemRam()
|
||||||
{
|
{
|
||||||
return [NSProcessInfo processInfo].physicalMemory;
|
static const size_t ram = [NSProcessInfo processInfo].physicalMemory;
|
||||||
|
return ram;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t SystemInfo::GetSystemRamAvailable()
|
size_t SystemInfo::GetSystemRamAvailable()
|
||||||
@@ -70,12 +71,14 @@ namespace OpenVulkano
|
|||||||
|
|
||||||
std::string SystemInfo::GetHostName()
|
std::string SystemInfo::GetHostName()
|
||||||
{
|
{
|
||||||
return [[NSProcessInfo processInfo].hostName UTF8String];
|
static const std::string hostName = [[NSProcessInfo processInfo].hostName UTF8String];
|
||||||
|
return hostName;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string SystemInfo::GetDeviceName()
|
std::string SystemInfo::GetDeviceName()
|
||||||
{
|
{
|
||||||
return [[[UIDevice currentDevice] name] UTF8String];
|
static const std::string devName = [[[UIDevice currentDevice] name] UTF8String];
|
||||||
|
return devName;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string SystemInfo::GetDeviceVendorName()
|
std::string SystemInfo::GetDeviceVendorName()
|
||||||
@@ -98,43 +101,67 @@ namespace OpenVulkano
|
|||||||
|
|
||||||
std::string SystemInfo::GetOsName()
|
std::string SystemInfo::GetOsName()
|
||||||
{
|
{
|
||||||
return [[[UIDevice currentDevice] systemName] UTF8String];
|
static const std::string osName = [[[UIDevice currentDevice] systemName] UTF8String];
|
||||||
|
return osName;
|
||||||
}
|
}
|
||||||
|
|
||||||
OsVersion SystemInfo::GetOsVersion()
|
OsVersion SystemInfo::GetOsVersion()
|
||||||
|
{
|
||||||
|
static OsVersion osv = {};
|
||||||
|
if (osv.major == 0 && osv.minor == 0)
|
||||||
{
|
{
|
||||||
NSOperatingSystemVersion osVersion = [NSProcessInfo processInfo].operatingSystemVersion;
|
NSOperatingSystemVersion osVersion = [NSProcessInfo processInfo].operatingSystemVersion;
|
||||||
return { static_cast<int>(osVersion.majorVersion), static_cast<int>(osVersion.minorVersion), static_cast<int>(osVersion.patchVersion), 0 };
|
osv = { static_cast<int>(osVersion.majorVersion), static_cast<int>(osVersion.minorVersion),
|
||||||
|
static_cast<int>(osVersion.patchVersion), 0 };
|
||||||
|
}
|
||||||
|
return osv;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string SystemInfo::GetOsNameHumanReadable()
|
std::string SystemInfo::GetOsNameHumanReadable()
|
||||||
|
{
|
||||||
|
static std::string hrName;
|
||||||
|
if (hrName.empty())
|
||||||
{
|
{
|
||||||
OsVersion osVersion = GetOsVersion();
|
OsVersion osVersion = GetOsVersion();
|
||||||
return fmt::format("{} {}.{}", GetOsName(), osVersion.major, osVersion.minor);
|
hrName = fmt::format("{} {}.{}", GetOsName(), osVersion.major, osVersion.minor);
|
||||||
|
}
|
||||||
|
return hrName;
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceType SystemInfo::GetDeviceType()
|
DeviceType SystemInfo::GetDeviceType()
|
||||||
|
{
|
||||||
|
static DeviceType devType = DeviceType::Unknown;
|
||||||
|
if (devType == DeviceType::Unknown)
|
||||||
{
|
{
|
||||||
switch ([UIDevice currentDevice].userInterfaceIdiom)
|
switch ([UIDevice currentDevice].userInterfaceIdiom)
|
||||||
{
|
{
|
||||||
case UIUserInterfaceIdiomPhone: return DeviceType::Phone;
|
case UIUserInterfaceIdiomPhone:
|
||||||
case UIUserInterfaceIdiomPad: return DeviceType::Tablet;
|
devType = DeviceType::Phone;
|
||||||
case UIUserInterfaceIdiomTV: return DeviceType::TV;
|
case UIUserInterfaceIdiomPad:
|
||||||
case UIUserInterfaceIdiomMac: return DeviceType::PC;
|
devType = DeviceType::Tablet;
|
||||||
case UIUserInterfaceIdiomVision: return DeviceType::VR;
|
case UIUserInterfaceIdiomTV:
|
||||||
default: break;
|
devType = DeviceType::TV;
|
||||||
|
case UIUserInterfaceIdiomMac:
|
||||||
|
devType = DeviceType::PC;
|
||||||
|
case UIUserInterfaceIdiomVision:
|
||||||
|
devType = DeviceType::VR;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return DeviceType::Unknown;
|
}
|
||||||
|
return devType;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t SystemInfo::GetCpuCoreCount()
|
size_t SystemInfo::GetCpuCoreCount()
|
||||||
{
|
{
|
||||||
return [NSProcessInfo processInfo].processorCount;
|
static const size_t coreCount = [NSProcessInfo processInfo].processorCount;
|
||||||
|
return coreCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t SystemInfo::GetCpuThreadCount()
|
size_t SystemInfo::GetCpuThreadCount()
|
||||||
{
|
{
|
||||||
return [NSProcessInfo processInfo].activeProcessorCount;
|
static const size_t threadCount = [NSProcessInfo processInfo].activeProcessorCount;
|
||||||
|
return threadCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t SystemInfo::GetCpuTemperature()
|
int32_t SystemInfo::GetCpuTemperature()
|
||||||
|
|||||||
Reference in New Issue
Block a user