Using StopWatch
Introduction
Provides a set of methods and properties that you can use to accurately measure elapsed time inside your code.
Installation
- npm
- yarn
- pnpm
npm install @sapphire/stopwatch
yarn add @sapphire/stopwatch
pnpm add @sapphire/stopwatch
Usage
- CommonJS
- ESM
- TypeScript
// Import the Stopwatch class
const { Stopwatch } = require('@sapphire/stopwatch');
// Create a new Stopwatch (which also starts it immediately)
const stopwatch = new Stopwatch();
// run other task here
console.log(stopwatch.stop().toString());
// 200ms
// Import the Stopwatch class
import { Stopwatch } from '@sapphire/stopwatch';
// Create a new Stopwatch (which also starts it immediately)
const stopwatch = new Stopwatch();
// run other task here
console.log(stopwatch.stop().toString());
// 200ms
// Import the Stopwatch class
import { Stopwatch } from '@sapphire/stopwatch';
// Create a new Stopwatch (which also starts it immediately)
const stopwatch = new Stopwatch();
// run other task here
console.log(stopwatch.stop().toString());
// 200ms