From bcecdc0454173d4e0b0a789d778343cb89040cdf Mon Sep 17 00:00:00 2001 From: Elanis Date: Wed, 8 Feb 2023 22:49:07 +0100 Subject: [PATCH] Sleep before/after originalFreeMemory --- runner/runner.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/runner/runner.js b/runner/runner.js index 9982f58a..7b5cfa9d 100644 --- a/runner/runner.js +++ b/runner/runner.js @@ -102,14 +102,23 @@ export function killAll(pid, signal='SIGTERM'){ } } +async function sleep(seconds) { + return (await new Promise((resolve, _reject) => { + setTimeout(resolve, seconds * 1000); + })); +} + async function getMemoryUsageHistoryOfProcess(processPath, processExe, timeout=DEFAULT_TIMEOUT) { - return new Promise((resolve, reject) => { + return new Promise(async(resolve, reject) => { let memUsageHistory = []; let sysMemUsageHistory = []; let startTime = '?'; let done = false; let time = 0; - let originalFreeMemory = os.freemem(); + + await sleep(5); + const originalFreeMemory = os.freemem(); + await sleep(1); // Spawn process const startTimestamp = performance.now();