1.0.5 • Published 4 years ago

logger-timer v1.0.5

Weekly downloads
25
License
MIT
Repository
github
Last release
4 years ago

LoggerTimer

A quick shortcut to adding a bunch of timers and dumping their deltas.

Install

npm i logger-timer

Reasoning

It can get a little tedious to do console.time/timeEnd, so I made this to track when you start / stop a timer. You can store multiple timers at once and dump them all to see the diagnostics. So, if you're making a game and want to profile your entire game loop overall, but simultaneously profile the individual calls, you just add more timers and dump them at the end.

Usage

import { LoggerTimer } from 'logger-timer';

const timer = new LoggerTimer();

timer.startTimer('loop');

for(let i = 0; i < 10000000; i++) {}

timer.stopTimer('loop');

// display the time taken
timer.dumpTimers();

Options

You can pass a few options into the LoggerTimer constructor:

  • isActive - whether or not the timer should be active. You can use this for ENV filtering.
  • dumpThreshold - a number that specifies the minimum threshold to dump timers for. This will allow you to ignore faster calls and show slower ones.
1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago