forked from rsmbl/Resemble.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
memory-leak-test.js
35 lines (29 loc) · 877 Bytes
/
memory-leak-test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// node --expose-gc memory-leak-test.js
const fs = require("fs");
const resemble = require("./resemble");
let max = 2000;
const timerLabel = "2000 compare";
console.time(timerLabel);
compare();
function compare() {
const people = fs.readFileSync("./demoassets/ghost1.png");
const people2 = fs.readFileSync("./demoassets/ghost2.png");
resemble(people)
.compareTo(people2)
.onComplete(() => {
if (--max >= 0) {
process.nextTick(compare);
} else {
process.nextTick(log);
}
global.gc();
if (max % 100 === 0) {
const mem = process.memoryUsage();
console.log(max, mem.rss, mem.heapUsed, mem.external);
}
});
}
function log() {
console.timeEnd(timerLabel);
process.exit(0); //eslint-disable-line
}