Merge commit '906afc5de9dd9df581be1a11393c4c7c5b549e45' as 'engine/strata'
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
// src/platform/memory_test.cpp - plan v0.3 P0.1: lock_resident on a 256 MiB region (CPU only, no GPU, no model).
|
||||
#include "strata/platform/memory.hpp"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#if defined(_WIN32)
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define NOMINMAX
|
||||
#include <windows.h>
|
||||
#include <psapi.h>
|
||||
#pragma comment(lib, "psapi.lib")
|
||||
#endif
|
||||
|
||||
int main() {
|
||||
const uint64_t bytes = 256ull << 20;
|
||||
void* p = std::malloc(bytes);
|
||||
if (p == nullptr) return 2;
|
||||
std::memset(p, 1, bytes);
|
||||
const strata::platform::LockResult r = strata::platform::lock_resident(p, bytes);
|
||||
std::printf("lock_resident: ok=%d locked=%llu MiB (%s)\n", (int) r.ok, (unsigned long long) (r.locked_bytes >> 20),
|
||||
r.note.c_str());
|
||||
int fail = !(r.ok && r.locked_bytes == bytes);
|
||||
#if defined(_WIN32)
|
||||
PROCESS_MEMORY_COUNTERS pmc{};
|
||||
GetProcessMemoryInfo(GetCurrentProcess(), &pmc, sizeof pmc);
|
||||
std::printf("working set %llu MiB\n", (unsigned long long) (pmc.WorkingSetSize >> 20));
|
||||
fail |= pmc.WorkingSetSize < bytes;
|
||||
#endif
|
||||
strata::platform::unlock_resident(p, bytes);
|
||||
std::free(p);
|
||||
std::printf("platform_memory_test: %s\n", fail ? "FAILED" : "OK");
|
||||
return fail;
|
||||
}
|
||||
Reference in New Issue
Block a user