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:
parent
1ac370632f
commit
f75eb12801
1 changed files with 9 additions and 4 deletions
|
@ -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);
|
||||
},
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue