timesteps
v1.0.1
Published
Interim time logging
Readme
TimeSteps is Node.js & Browser compatible
Natively uses process.hrtime (node) if available, otherwise it uses performance.now (browser).
Example
const investigator = new TimeSteps("Mr. Investigate");
investigator.step("Investigator on the case.");
madeUpFunction(true, false, true);
investigator.step("madeUpFunction");
oldMateBottleNeck();
investigator.step("oldMateBottleNeck");
anotherMadeUpFunction("truthy", null + null);
investigator.step("anotherMadeUpFunction");
CONSOLE LOG OUTPUT:
[Mr. Investigate] Investigator on the case. (0ms)
[Mr. Investigate] madeUpFunction (300.962ms)
[Mr. Investigate] oldMateBottleNeck (5196.192ms)
[Mr. Investigate] anotherMadeUpFunction (307.101ms)Installation
NPM
npm i timestepsconst TimeSteps = require("timesteps");
const myTimeLogger = new TimeSteps("my time logger label");Browser
- Copy the code from
TimeSteps.mint.jsinto a file in your project - Reference the created file in your HTML
<script src="(link/to/file)"></script>
TimeSteps.mint.jsis the minified & transformed (es2015) version
or use jsdelivr:
https://cdn.jsdelivr.net/npm/[email protected]/TimeSteps.mint.js
Usage
// Instantiate
const tim = new TimeSteps("Timothy the timer");
// Add steps
tim.step("Tim's first steps!");
// ^ this invokes console.log
// Reset the interim timer - useful for when you want to skip through callback hell
tim.reset();
