A simple stopwatch app that allows you to start, stop, and reset the timer. Intended to be used for timing functions calls in JavaScript/TypeScript.
npm install stopwatch-dev
import { Stopwatch } from "stopwatch-dev";
// create instance
const stopwatch = new Stopwatch();
// measure function call execution time
stopwatch.start();
expensiveFunction();
stopwatch.stop();
// get duration and access values...
const duration = stopwatch.duration();
const millies = stopwatch.millies();
const seconds = stopwatch.seconds();
const minutes = stopwatch.minutes();
const hours = stopwatch.hours();
// ... or get complete millieseconds
const totalMillies = stopwatch.duration();
// ... or print the duration
console.log(duration);
// prints: 1:23:45.678 (hours:minutes:seconds.millies)
To run the tests, use the following command:
pnpm test
This project is licensed under the MIT License - see the LICENSE file for details.