Hi there is some nodejs code as follow:
console.log("Start", new Date().getTime());
var fs = require('fs');
for (var i = 1; i < 10; i++) {
fs.readFile("file1.zip",function(err, data) {
if(err)
console.log("read error: ", err);
else {
fs.writeFile(__dirname + "/file2.zip", data , function(err) {
if(err) {
console.log("write error: ", err);
}
});
}
});
};
console.log("Finished", new Date().getTime());
I want to get the start and finish time when all the work is done, but it seems like the the second log is too early
Instead of
console.log("Finished", new Date().getTime());you might want to try: