-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtest.js
55 lines (50 loc) · 1.39 KB
/
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
var nodegc = require('./index');
var should = require('should');
var scavenge = null, marksweep = null;
nodegc.on('scavenge', function(info) {
scavenge = info;
});
nodegc.on('marksweep', function(info) {
marksweep = info;
});
describe("V8 GC events", function() {
before(function() {
});
it('should fire some scavenge events', function(done) {
for (var m = 0; m < 1000; m++) {
var a = [];
for (var o = 0; o < 1000; o++) {
a.push('foo'+o);
}
}
setTimeout(function() {
console.log(scavenge);
scavenge.should.not.be.null;
scavenge.duration.should.be.above(0);
scavenge.duration.should.be.below(1000);
scavenge.heapBefore.should.be.above(1000);
scavenge.heapAfter.should.be.above(1000);
done()
}, 100);
});
it('should fire some mark&sweep events after applying some memory pressure', function(done) {
this.timeout(5000);
var all = []
for (var m = 0; m < 1000; m++) {
var a = [];
for (var o = 0; o < 10000; o++) {
a.push('foo'+o);
all.push('bar'+o);
}
}
setTimeout(function() {
console.log(marksweep);
marksweep.should.not.be.null;
marksweep.duration.should.be.above(0);
marksweep.duration.should.be.below(1000);
marksweep.heapBefore.should.be.above(1000);
marksweep.heapAfter.should.be.above(1000);
done()
}, 100);
});
});