mirror of
https://github.com/copyrighttxt/watrbx-game-engine.git
synced 2026-09-04 20:57:49 +00:00
GEEKING
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
|
||||
#include "rbx/test/Performance.h"
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "Windows.h"
|
||||
#elif defined(__APPLE__)
|
||||
#include <sys/types.h>
|
||||
#include <sys/sysctl.h>
|
||||
#endif
|
||||
|
||||
RBX::Test::Memory::Memory()
|
||||
{
|
||||
initialBytes = 0;
|
||||
initialBytes = GetBytes();
|
||||
}
|
||||
|
||||
long RBX::Test::Memory::GetBytes()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
MEMORYSTATUSEX status;
|
||||
status.dwLength = sizeof(MEMORYSTATUSEX);
|
||||
BOOST_REQUIRE(GlobalMemoryStatusEx(&status));
|
||||
// This ain't pretty, but it is notoriously hard to get a good value for bytes used by a process:
|
||||
return (long)status.ullTotalVirtual - (long)status.ullAvailVirtual - initialBytes;
|
||||
#else
|
||||
|
||||
// "MACPORT: TBD for now, implementing something however we need to discuss how to handle this properly"
|
||||
int mib[2];
|
||||
uint64_t memsize;
|
||||
size_t len;
|
||||
|
||||
mib[0] = CTL_HW;
|
||||
mib[1] = HW_MEMSIZE; /*uint64_t: physical ram size */
|
||||
len = sizeof(memsize);
|
||||
sysctl(mib, 2, &memsize, &len, NULL, 0);
|
||||
|
||||
return (long)memsize;
|
||||
|
||||
#endif
|
||||
}
|
||||
Reference in New Issue
Block a user