1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-22 15:24:46 -05:00

test(ext/node): compare free memory in log scale (#21475)

This commit is contained in:
Yoshiya Hinosawa 2023-12-07 00:32:39 +09:00 committed by GitHub
parent 1ac370632f
commit f75eb12801
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -290,13 +290,18 @@ Deno.test({
},
});
// Gets the diff in log_10 scale
function diffLog10(a: number, b: number): number {
return Math.abs(Math.log10(a) - Math.log10(b));
}
Deno.test({
name:
"os.freemem() is equivalent of Deno.systemMemoryInfo().free except on linux",
ignore: Deno.build.os === "linux",
fn() {
const diff = Math.abs(os.freemem() - Deno.systemMemoryInfo().free);
assert(diff < 10_000);
const diff = diffLog10(os.freemem(), Deno.systemMemoryInfo().free);
assert(diff < 1);
},
});
@ -305,7 +310,7 @@ Deno.test({
"os.freemem() is equivalent of Deno.systemMemoryInfo().available on linux",
ignore: Deno.build.os !== "linux",
fn() {
const diff = Math.abs(os.freemem() - Deno.systemMemoryInfo().available);
assert(diff < 10_000);
const diff = diffLog10(os.freemem(), Deno.systemMemoryInfo().available);
assert(diff < 1);
},
});