'Node JS file write time [duplicate]
I have code that writes data to a file, how can it be done to show how much time it took to write a file?
const fs = require("fs");
fs.writeFile('./text.json', JSON.stringify(m), (err) => {
if (err) console.log(err);
});
Solution 1:[1]
you can do something like this:
/*
time from unix epoch in milliseconds = new Date().getTime();
*/
const currentTime = new Date().getTime();
// Some operation here
const timeNow = new Date().getTime();
const timeTookInMilliseconds = timeNow - currentTime;
You can read more here: MDN
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
