Skip to content
This repository has been archived by the owner on Jan 24, 2023. It is now read-only.

FLzyy/timebench

Repository files navigation

timebench

npm version npm downloads CodeFactor

Small little helper class for timing and benchmarking things.

Basic Usage

import Timer from "timebench";

const timer = new Timer();

veryLongToExecuteFunction();

timer.end();

const times = timer.time();

console.log(times.ns, times.ms, times.s); // Nanoseconds, Milliseconds, and Seconds

API

new Timer()

Creates a new Timer object and starts it.

<Timer>.start()

Starts the timer, requires for the timer to have been restarted.

<Timer>.end()

Ends the timer, requires for the timer to have been started.

<Timer>.reset()

Resets the timer back to 0ns.

<Timer>.time

Returns nanoseconds, millisecond, and seconds elasped since Timer has been started and ended.

<Timer>.stored

Returns all lapped times with the instantiated Class.

<Timer>.lap()

Stores current elapsed in the stored variable