New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

time-perf

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

time-perf

A simple object to evaluate the performance of a function|application|algorithm

latest
Source
npmnpm
Version
2.0.2
Version published
Weekly downloads
13
62.5%
Maintainers
1
Weekly downloads
 
Created
Source

TimePerf

light performance measure tool

TimePerf is a simple npm module to evaluate et measure a javascript application. TimePerf is a singleton it can be require in through several modules/files.

Documentation (click here)

Installation

npm install time-perf

Quick start

var timePerf = require('time-perf');

timePerf.start('Test');
// ..execute algorithm to evaluate
timePerf.step('Algorithm').print();
// Will display "> 1. Algorithm : 127 ms"

// ..execute a function to evaluate
timePerf.stop('Function').print();

timePerf.print();
// Will display :

--------------------------------
-         TimePerf result      -
--------------------------------
# Test
 + TimePerf duration   : 200 ms
 + Pause duration   : 0 ms

 > 1. Algorithm   : 63.5 % (127 ms)
 > 2. Function    : 36.5 % (73 ms)

Latest features :

We know you wanted to do this, at least we wanted to: get/create identified TimePerf instance

  • You can now create new TimePerf instance and access it through the TimePerf singleton with the newInstance/getInstance function

Rename for better readibility

  • Better use print to print measure durations (resume still an alias)
  • For permanent duration measure and easiest duration analysis use getTime(index)

TimePerf made some children ! You can now create children in each step.

  • To do it use child or even faster childStart and childStop to make quick child. A child is a TimePerf object you can use it as its parent. You can add as much child and as deep as you want to.
Use example
timePerf.start('Test').childStart('SmallChild 1');
// .. some stuff
timePerf.childStop().childStart('SmallChild 2');
// .. more stuff
timePerf.lastChild().stop();
timePerf.step('Parent 1');
var perfChild = timePerf.child().start('BigChild');//same as timePerf.childStart('BigChild')
// ..inside step
perfChild.step('inside step 1');
timePerf.childStop('inside step 2').stop('Parent 2').print();

// Will display
--------------------------------
-         TimePerf result      -
--------------------------------
## Test
+ TimePerf duration : 19609 ms
+ Pause duration    : 0 ms
> 1. Parent 1	: 0.54 %	(105 ms)
	> SmallChild 1	: 12 ms
	> SmallChild 2	: 92 ms
> 2. Parent 2	: 99.46 %	(19504 ms)
	## BigChild
	+ TimePerf duration : 19504 ms
	+ Pause duration    : 0 ms
	> 1. inside step 1	: 65.56 %	(12787 ms)
	> 2. inside step 2	: 34.44 %	(6717 ms)

More features

  • TimePerf functions can be chained
  • You can pause and unpause
  • TimePerf can display any previous action result with log
  • print will display the last step result when chained to step
timePerf.start();
timePerf.step("First step").print().pause();
// display "\[TimePerf] > 1. First Step : 20 ms"

timePerf.unpause().log();
// display "TimePerf has marked a 4 ms pause"
  • stop will step and pause TimePerf
timePerf.stop("Last step");
//..
timePerf.unpause()
  • start will reset and step TimePerf. You can call it at any time to restart TimePerf

Dev

To regenerate documentation jsdoc --configure documentation/jsdoc.json

Keywords

performance

FAQs

Package last updated on 16 Nov 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts