A simple JS/TS Stopwatch with 0 dependency.
This is inspired by the Spring-Stopwatch. Written in Typescript
, 100%` Test Coverage.
Install
npm install stopwatch-node
Example
; const sleep = ; async { const sw = 'sw'; swstart'Task 1'; await ; sw; // whether the stop watch is currently running console; const task2Name = 'Task 2'; swstarttask2Name; await ; sw; swstart'Task 3'; await ; sw; swstart'Task 4'; await ; sw; console; console; // a table describing all tasks performed sw; const task2 = sw; console
Output
------------------------------------------
ms % Task name
------------------------------------------
1000 30.21 Task 1
1504 45.44 Task 2
505 15.26 Task 3
301 9.09 Task 4
'Task 2' took 1506 and percentage is 45.47