From 9f02ce05909014043c797ac402bd318c73aac604 Mon Sep 17 00:00:00 2001 From: Nick Briggs Date: Mon, 12 Feb 2024 09:30:46 -0800 Subject: [PATCH] Emscripten/wasm does not support getrusage() system call Updating the MiscStats data can at best provide the time of day and attribute all elapsed time to total CPU time. Closes issue #1537 --- src/timer.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/timer.c b/src/timer.c index 08a5874..ef91303 100644 --- a/src/timer.c +++ b/src/timer.c @@ -118,6 +118,19 @@ void update_miscstats(void) { MiscStats->diskiotime = 0; /* ?? not available ?? */ MiscStats->diskops = 0; MiscStats->secondstmp = MiscStats->secondsclock = (time(0) + UNIX_ALTO_TIME_DIFF); +#elif defined(MAIKO_OS_EMSCRIPTEN) + /* Emscripten does not provide getrusage() functionality */ + struct timeval timev; + + MiscStats->totaltime = gettime(0) - MiscStats->starttime; + MiscStats->swapwaittime = 0; + MiscStats->pagefaults = 0; + MiscStats->swapwrites = 0; + MiscStats->diskiotime = 0; + MiscStats->diskops = 0; + + gettimeofday(&timev, NULL); + MiscStats->secondstmp = MiscStats->secondsclock = (timev.tv_sec + UNIX_ALTO_TIME_DIFF); #else struct timeval timev; struct rusage ru;