Socket
Book a DemoInstallSign in
Socket

measure-it

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

measure-it

Measure performance of code blocks

1.0.1
latest
npmnpm
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

measure-it

NPM version NPM downloads Build Status

Measure performance of code blocks

Install

npm install measure-it --save

Usage

Measure One

const measureOf = require('measure-it');

let measure = measureOf('Awesome Code').start();

awesomeCode();

console.log(measure.get());
// 10

console.log(measure.serialize());
// <Awesome Code> 10

Measure Multiple Groups

const measureOf = require('measure-it');

let measure = measureOf('Awesome Code');

measure.start('block 1');

awesomeCode();

measure.stop('block 1').start('block 2');

awesomeCode();

measure.stop('block 2');

console.log(measure.get('block 1'));
// 11
console.log(measure.get('block 2'));
// 12

console.log(measure.serialize());
// <Awesome Code> block 1: 11, block 2: 12

Measure Asynchronous Code Blocks

const measureOf = require('measure-it');

let measure = measureOf('Awesome Code');

measure.start('block 1');

setTimeout(() => {
  measure.stop('block 1').start('block 2');
  console.log(measure.get('block 1'));
  // 1000

  setTimeout(() => {
    measure.stop('block 2');
    console.log(measure.get('block 2'));
    // 1000

    console.log(measure.serialize());
    // <Awesome Code> block 1: 1000, block 2: 1000
  }, 1000);
}, 1000);

Start / Stop Multiple Groups At Once

const measureOf = require('measure-it');

let measure = measureOf('Awesome Code').start('block 1', 'block 2', 'block 3');

awesomeCode();

measure.stop('block 1');

awesomeCode();

measure.stop('block 2', 'block 3');

console.log(measure.get('block 1'));
// 10
console.log(measure.get('block 2'));
// 20
console.log(measure.get('block 3'));
// 20

console.log(measure.serialize());
// <Awesome Code> block 1: 10, block 2: 20, block 3: 20

Measure Progression

const measureOf = require('measure-it');

let measure = measureOf('Awesome Code').start();

awesomeCode();

measure.stop();

awesomeCode();

measure.stop();

console.log(measure.get());
// [10, 20]

console.log(measure.serialize());
// <Awesome Code> 10, 20

Keywords

measure

FAQs

Package last updated on 02 Mar 2017

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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.