Skip to content

Commit

Permalink
Change test order due to a strange behaviour of memwatch
Browse files Browse the repository at this point in the history
  • Loading branch information
paulvalla committed Jul 3, 2014
1 parent ec59def commit 7853a17
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 47 deletions.
4 changes: 2 additions & 2 deletions test/testrunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ testrunner.run([
{
code: path + '/lib/crawler.js',
tests: [
path + '/test/units/leaks.js',
path + '/test/units/simple.js',
path + '/test/units/links.js',
path + '/test/units/forceutf8.js',
path + '/test/units/errors.js',
path + '/test/units/leaks.js'
path + '/test/units/errors.js'
]
}
],function(err, report) {
Expand Down
89 changes: 44 additions & 45 deletions test/units/leaks.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var _ = require('underscore');
var memwatch = require('memwatch');


QUnit.module('links');
QUnit.module('leaks');

var DEBUG = false;
var MOCKPORT = 30045;
Expand All @@ -23,22 +23,21 @@ test('Check that we do leak w/ 100 jsdom requests without autoWindowClose', func
retryTimeout: 1000,
retries: 1,
onDrain: function() {
hd = new memwatch.HeapDiff();
// // Wait a bit for the GC to kick in
// setTimeout(function() {
// Wait a bit for the GC to kick in
setTimeout(function() {
start();

// var diff = hd.end();
console.log('Bytes added to memory',diff.change.size_bytes);
//
// Should have grown by more than 50 MB.
// ok(diff.change.size_bytes > 50000000);
// }, 10000);
var diff = hd.end();
console.log('Bytes added to memory', diff.change.size_bytes);

//Should have grown by more than 50 MB.
ok(diff.change.size_bytes > 50000000);
}, 10000);
}
});
hd = new memwatch.HeapDiff();


console.log('Queueing '+N+' requests w/ jsdom and autoWindowClose=false...');
console.log('Queueing '+ N +' requests w/ jsdom and autoWindowClose=false...');
for (var i=0; i<N; i++) {
c.queue([{
uri:'http://127.0.0.1:'+MOCKPORT+'/bigpage?i='+i,
Expand All @@ -47,36 +46,36 @@ test('Check that we do leak w/ 100 jsdom requests without autoWindowClose', func
}
});

//test('Crawl 10k URLs and check memory/speed without jsdom', function() {
// expect(1);
// stop();
//
// var N = 10000;
// var hd;
// var c = new Crawler({
// debug: false,
// jQuery: false,
// timeout: 500,
// retryTimeout: 1000,
// retries: 1,
// onDrain: function() {
// start();
// // Wait a bit for the GC to kick in
// setTimeout(function() {
// var diff = hd.end();
// console.log('Bytes added to memory', diff.change.size_bytes);
// //Shouldn't have grown by more than 10 MB.
// ok(diff.change.size_bytes < 10000000);
// }, 10000);
// }
// });
// hd = new memwatch.HeapDiff();
//
// console.log('Queueing '+N+' requests w/o jsdom...');
// for (var i=0; i<N; i++) {
// c.queue([{
// uri:'http://127.0.0.1:'+MOCKPORT+'/bigpage?i='+i,
// callback:function(error,result,$) {}
// }]);
// }
//});
test('Crawl 10k URLs and check memory/speed without jsdom', function() {
expect(1);
stop();

var N = 10000;
var hd;
var c = new Crawler({
debug: false,
jQuery: false,
timeout: 500,
retryTimeout: 1000,
retries: 1,
onDrain: function() {
// Wait a bit for the GC to kick in
setTimeout(function() {
start();
var diff = hd.end();
console.log('Bytes added to memory', diff.change.size_bytes);
//Shouldn't have grown by more than 10 MB.
ok(diff.change.size_bytes < 10000000);
}, 10000);
}
});
hd = new memwatch.HeapDiff();

console.log('Queueing '+ N +' requests w/o jsdom...');
for (var i = 0; i < N; i++) {
c.queue([{
uri:'http://127.0.0.1:'+MOCKPORT+'/bigpage?i='+i,
callback:function(error, result, $) {}
}]);
}
});

0 comments on commit 7853a17

Please sign in to comment.