SysInfo caching for MacOS
This commit is contained in:
@@ -24,7 +24,12 @@ namespace OpenVulkano
|
||||
|
||||
size_t SystemInfo::GetSystemRam()
|
||||
{
|
||||
return [NSProcessInfo processInfo].physicalMemory;
|
||||
static size_t ram;
|
||||
if (ram == 0)
|
||||
{
|
||||
ram = [NSProcessInfo processInfo].physicalMemory;
|
||||
}
|
||||
return ram;
|
||||
}
|
||||
|
||||
size_t SystemInfo::GetSystemRamAvailable()
|
||||
@@ -67,12 +72,22 @@ namespace OpenVulkano
|
||||
|
||||
std::string SystemInfo::GetHostName()
|
||||
{
|
||||
return [[NSProcessInfo processInfo].hostName UTF8String];
|
||||
static std::string hostName;
|
||||
if (hostName.empty())
|
||||
{
|
||||
hostName = [[NSProcessInfo processInfo].hostName UTF8String];
|
||||
}
|
||||
return hostName;
|
||||
}
|
||||
|
||||
std::string SystemInfo::GetDeviceName()
|
||||
{
|
||||
return "Mac"; //TODO
|
||||
static std::string devName;
|
||||
if (devName.empty())
|
||||
{
|
||||
devName = "Mac"; //TODO
|
||||
}
|
||||
return devName;
|
||||
}
|
||||
|
||||
std::string SystemInfo::GetDeviceVendorName()
|
||||
@@ -82,9 +97,14 @@ namespace OpenVulkano
|
||||
|
||||
std::string SystemInfo::GetDeviceModelName()
|
||||
{
|
||||
struct utsname systemInfo;
|
||||
uname(&systemInfo);
|
||||
return systemInfo.machine;
|
||||
static std::string machine;
|
||||
if (machine.empty())
|
||||
{
|
||||
struct utsname systemInfo;
|
||||
uname(&systemInfo);
|
||||
machine = systemInfo.machine;
|
||||
}
|
||||
return machine;
|
||||
}
|
||||
|
||||
std::string SystemInfo::GetOsName()
|
||||
@@ -94,15 +114,26 @@ namespace OpenVulkano
|
||||
|
||||
OsVersion SystemInfo::GetOsVersion()
|
||||
{
|
||||
NSOperatingSystemVersion osVersion = [NSProcessInfo processInfo].operatingSystemVersion;
|
||||
return { static_cast<int>(osVersion.majorVersion), static_cast<int>(osVersion.minorVersion), static_cast<int>(osVersion.patchVersion), 0 };
|
||||
static OsVersion osVersion;
|
||||
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::stringstream name;
|
||||
name << GetOsName() << ' ' << GetOsVersion().major;
|
||||
return name.str();
|
||||
static std::string hrName;
|
||||
if (hrName.empty())
|
||||
{
|
||||
std::stringstream name;
|
||||
name << GetOsName() << ' ' << GetOsVersion().major;
|
||||
hrName = name.str();
|
||||
}
|
||||
return hrName;
|
||||
}
|
||||
|
||||
DeviceType SystemInfo::GetDeviceType()
|
||||
@@ -112,12 +143,22 @@ namespace OpenVulkano
|
||||
|
||||
size_t SystemInfo::GetCpuCoreCount()
|
||||
{
|
||||
return [NSProcessInfo processInfo].processorCount;
|
||||
static size_t coreCount;
|
||||
if (coreCount == 0)
|
||||
{
|
||||
coreCount = [NSProcessInfo processInfo].processorCount;
|
||||
}
|
||||
return coreCount;
|
||||
}
|
||||
|
||||
size_t SystemInfo::GetCpuThreadCount()
|
||||
{
|
||||
return [NSProcessInfo processInfo].activeProcessorCount;
|
||||
static size_t procCount;
|
||||
if (procCount == 0)
|
||||
{
|
||||
procCount = [NSProcessInfo processInfo].activeProcessorCount;
|
||||
}
|
||||
return procCount;
|
||||
}
|
||||
|
||||
int32_t SystemInfo::GetCpuTemperature()
|
||||
|
||||
Reference in New Issue
Block a user