1.1.1 • Published 3 years ago
stopwatch-lite v1.1.1
stopwatch-lite
A stopwatch for all your time-measuring needs
Installing
npm install stopwatch-lite
Usage
import stopwatch from "stopwatch-lite";
stopwatch.start();
...
stopwatch.stop();
console.log(stopwatch.read());
import sw from "stopwatch-lite";
sw.start("example");
sw.start(123);
foo().then(() => {
sw.stop("example");
});
bar().then(() => {
sw.stop(123);
});
console.log(`foo execution time: ${sw.read("example")} ms`);
console.log(`bar execution time: ${sw.read(123)} ms`);
import sw from "stopwatch-lite";
let totalExecutionTime = 0;
for (let i = 0; i < 42; i++) {
sw.start();
foo();
totalExecutionTime += sw.read();
sw.reset();
}
console.log(`average execution time: ${totalExecutionTime / 42} ms`);