rodrigobranas/youtube

NodeJS_1_Introducao/files.js Warning: No such label 'file' for console.timeEnd()

souzace opened this issue · 0 comments

For some reason, console.time and console.timeEnd, just work inside scope of function fs.readFile:

Original:

console.time('file');
var thread = 1;
var count = 1;
while(count <= 6) {
	fs.readFile('./file.mov', function (err, data) {
		console.log("Thread #" + thread++ + " finish");
		console.timeEnd('file');
	});
	count++;
}

My:

var thread = 1;
var count = 1;
while(count <= 6) {
    fs.readFile('./imagem.iso', function (err, data) {
                console.time('file');
	        console.log("Thread #" + thread++ + " finish");
		console.timeEnd('file');
	});
	count++;
}

My node version v6.11.2