Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var Tensor = require('../THTensor');
//var Tensor = require('../tensor');
var ad = require('../ad');
var nn = require('../nn');
var opt = require('../opt');
var profiler = require('gc-profiler');
//Profile GC
// node --inspect test/gc.js
var numT = 10000;
var sizeT = 1000
console.time('tensor');
profiler.on('gc', function (info) {
console.log(info);
});
while (numT-- > 0) {
var t = new Tensor([sizeT,sizeT]).fill(0);
}
console.timeEnd('tensor');
function start () {
if (running) {
return;
}
running = true;
clearEvents();
Gc.on('gc', gcEventHandler);
}
stream.once('resume', function () {
profiler.on('gc', function (info) {
gcSample = process.memoryUsage()
if (opts.ts) gcSample.ts = Date.now()
gcSample.gc = info.type
})
})
}
function stop () {
if (!running) {
return;
}
running = false;
clearEvents();
Gc.removeListener('gc', gcEventHandler);
}