Address review comments
This commit is contained in:
parent
35f7f5e3e3
commit
de1fe7e6e3
@ -61,6 +61,7 @@
|
|||||||
#include "common/common_paths.h"
|
#include "common/common_paths.h"
|
||||||
#include "common/detached_tasks.h"
|
#include "common/detached_tasks.h"
|
||||||
#include "common/file_util.h"
|
#include "common/file_util.h"
|
||||||
|
#include "common/literals.h"
|
||||||
#include "common/logging/backend.h"
|
#include "common/logging/backend.h"
|
||||||
#include "common/logging/filter.h"
|
#include "common/logging/filter.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
@ -214,10 +215,10 @@ GMainWindow::GMainWindow()
|
|||||||
LOG_INFO(Frontend, "Host CPU: {}", cpu_string);
|
LOG_INFO(Frontend, "Host CPU: {}", cpu_string);
|
||||||
#endif
|
#endif
|
||||||
LOG_INFO(Frontend, "Host OS: {}", QSysInfo::prettyProductName().toStdString());
|
LOG_INFO(Frontend, "Host OS: {}", QSysInfo::prettyProductName().toStdString());
|
||||||
LOG_INFO(Frontend, "Host RAM: {:.2f} GB",
|
const auto& mem_info = Common::GetMemInfo();
|
||||||
Common::GetMemInfo().TotalPhysicalMemory / 1024.0f / 1024 / 1024);
|
using namespace Common::Literals;
|
||||||
LOG_INFO(Frontend, "Host Swap: {:.2f} GB",
|
LOG_INFO(Frontend, "Host RAM: {:.2f} GiB", mem_info.total_physical_memory / f64{1_GiB});
|
||||||
Common::GetMemInfo().TotalSwapMemory / 1024.0f / 1024 / 1024);
|
LOG_INFO(Frontend, "Host Swap: {:.2f} GiB", mem_info.total_swap_memory / f64{1_GiB});
|
||||||
UpdateWindowTitle();
|
UpdateWindowTitle();
|
||||||
|
|
||||||
show();
|
show();
|
||||||
|
@ -74,6 +74,7 @@ add_library(common STATIC
|
|||||||
file_util.h
|
file_util.h
|
||||||
hash.h
|
hash.h
|
||||||
linear_disk_cache.h
|
linear_disk_cache.h
|
||||||
|
literals.h
|
||||||
logging/backend.cpp
|
logging/backend.cpp
|
||||||
logging/backend.h
|
logging/backend.h
|
||||||
logging/filter.cpp
|
logging/filter.cpp
|
||||||
|
31
src/common/literals.h
Normal file
31
src/common/literals.h
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
// Copyright 2021 yuzu emulator team
|
||||||
|
// Licensed under GPLv2 or any later version
|
||||||
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "common/common_types.h"
|
||||||
|
|
||||||
|
namespace Common::Literals {
|
||||||
|
|
||||||
|
constexpr u64 operator""_KiB(unsigned long long int x) {
|
||||||
|
return 1024ULL * x;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr u64 operator""_MiB(unsigned long long int x) {
|
||||||
|
return 1024_KiB * x;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr u64 operator""_GiB(unsigned long long int x) {
|
||||||
|
return 1024_MiB * x;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr u64 operator""_TiB(unsigned long long int x) {
|
||||||
|
return 1024_GiB * x;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr u64 operator""_PiB(unsigned long long int x) {
|
||||||
|
return 1024_TiB * x;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Common::Literals
|
@ -3,10 +3,9 @@
|
|||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// clang-format off
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
// Depends on <windows.h> coming first
|
||||||
#include <sysinfoapi.h>
|
#include <sysinfoapi.h>
|
||||||
// clang-format on
|
|
||||||
#else
|
#else
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#if defined(__APPLE__) || defined(__FreeBSD__)
|
#if defined(__APPLE__) || defined(__FreeBSD__)
|
||||||
@ -23,15 +22,15 @@
|
|||||||
namespace Common {
|
namespace Common {
|
||||||
|
|
||||||
// Detects the RAM and Swapfile sizes
|
// Detects the RAM and Swapfile sizes
|
||||||
static MemoryInfo Detect() {
|
const MemoryInfo GetMemInfo() {
|
||||||
MemoryInfo mem_info{};
|
MemoryInfo mem_info{};
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
MEMORYSTATUSEX memorystatus;
|
MEMORYSTATUSEX memorystatus;
|
||||||
memorystatus.dwLength = sizeof(memorystatus);
|
memorystatus.dwLength = sizeof(memorystatus);
|
||||||
GlobalMemoryStatusEx(&memorystatus);
|
GlobalMemoryStatusEx(&memorystatus);
|
||||||
mem_info.TotalPhysicalMemory = memorystatus.ullTotalPhys;
|
mem_info.total_physical_memory = memorystatus.ullTotalPhys;
|
||||||
mem_info.TotalSwapMemory = memorystatus.ullTotalPageFile - mem_info.TotalPhysicalMemory;
|
mem_info.total_swap_memory = memorystatus.ullTotalPageFile - mem_info.total_physical_memory;
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
u64 ramsize;
|
u64 ramsize;
|
||||||
struct xsw_usage vmusage;
|
struct xsw_usage vmusage;
|
||||||
@ -42,32 +41,27 @@ static MemoryInfo Detect() {
|
|||||||
// sysctlbyname(const char *, void *, size_t *, void *, size_t);
|
// sysctlbyname(const char *, void *, size_t *, void *, size_t);
|
||||||
sysctlbyname("hw.memsize", &ramsize, &sizeof_ramsize, nullptr, 0);
|
sysctlbyname("hw.memsize", &ramsize, &sizeof_ramsize, nullptr, 0);
|
||||||
sysctlbyname("vm.swapusage", &vmusage, &sizeof_vmusage, nullptr, 0);
|
sysctlbyname("vm.swapusage", &vmusage, &sizeof_vmusage, nullptr, 0);
|
||||||
mem_info.TotalPhysicalMemory = ramsize;
|
mem_info.total_physical_memory = ramsize;
|
||||||
mem_info.TotalSwapMemory = vmusage.xsu_total;
|
mem_info.total_swap_memory = vmusage.xsu_total;
|
||||||
#elif defined(__FreeBSD__)
|
#elif defined(__FreeBSD__)
|
||||||
u_long physmem, swap_total;
|
u_long physmem, swap_total;
|
||||||
std::size_t sizeof_u_long = sizeof(u_long);
|
std::size_t sizeof_u_long = sizeof(u_long);
|
||||||
// sysctlbyname(const char *, void *, size_t *, const void *, size_t);
|
// sysctlbyname(const char *, void *, size_t *, const void *, size_t);
|
||||||
sysctlbyname("hw.physmem", &physmem, &sizeof_u_long, nullptr, 0);
|
sysctlbyname("hw.physmem", &physmem, &sizeof_u_long, nullptr, 0);
|
||||||
sysctlbyname("vm.swap_total", &swap_total, &sizeof_u_long, nullptr, 0);
|
sysctlbyname("vm.swap_total", &swap_total, &sizeof_u_long, nullptr, 0);
|
||||||
mem_info.TotalPhysicalMemory = physmem;
|
mem_info.total_physical_memory = physmem;
|
||||||
mem_info.TotalSwapMemory = swap_total;
|
mem_info.total_swap_memory = swap_total;
|
||||||
#elif defined(__linux__)
|
#elif defined(__linux__)
|
||||||
struct sysinfo meminfo;
|
struct sysinfo meminfo;
|
||||||
sysinfo(&meminfo);
|
sysinfo(&meminfo);
|
||||||
mem_info.TotalPhysicalMemory = meminfo.totalram;
|
mem_info.total_physical_memory = meminfo.totalram;
|
||||||
mem_info.TotalSwapMemory = meminfo.totalswap;
|
mem_info.total_swap_memory = meminfo.totalswap;
|
||||||
#else
|
#else
|
||||||
mem_info.TotalPhysicalMemory = sysconf(_SC_PHYS_PAGES) * sysconf(_SC_PAGE_SIZE);
|
mem_info.total_physical_memory = sysconf(_SC_PHYS_PAGES) * sysconf(_SC_PAGE_SIZE);
|
||||||
mem_info.TotalSwapMemory = 0;
|
mem_info.total_swap_memory = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return mem_info;
|
return mem_info;
|
||||||
}
|
}
|
||||||
|
|
||||||
const MemoryInfo& GetMemInfo() {
|
} // namespace Common
|
||||||
static MemoryInfo mem_info = Detect();
|
|
||||||
return mem_info;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Common
|
|
||||||
|
@ -9,14 +9,14 @@
|
|||||||
namespace Common {
|
namespace Common {
|
||||||
|
|
||||||
struct MemoryInfo {
|
struct MemoryInfo {
|
||||||
u64 TotalPhysicalMemory{};
|
u64 total_physical_memory{};
|
||||||
u64 TotalSwapMemory{};
|
u64 total_swap_memory{};
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the memory info of the host system
|
* Gets the memory info of the host system
|
||||||
* @return Reference to a MemoryInfo struct with the physical and swap memory sizes in bytes
|
* @return Reference to a MemoryInfo struct with the physical and swap memory sizes in bytes
|
||||||
*/
|
*/
|
||||||
const MemoryInfo& GetMemInfo();
|
[[nodiscard]] const MemoryInfo GetMemInfo();
|
||||||
|
|
||||||
} // namespace Common
|
} // namespace Common
|
||||||
|
Loading…
Reference in New Issue
Block a user