Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

exec-timer

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

exec-timer

Measure execution time of functions and promises in Milliseconds

  • 0.0.9
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

Execution Timer

Measure execution time of functions and promises in Milliseconds

npm install exec-timer

const timer = require('exec-timer');
function f (param1, param2) {
    return `f -> ${param1}+${param2}`;
}

let result = timer.measure('function f()', (end) => {
    end();
    return f('a', 'b');
});

console.log(timer.get('function f()'));
function cb (param1, param2, callback) {
    setTimeout(() => {
        callback(`cb -> ${param1}+${param2}`);
    }, 500);
}

timer.measure('function cb()', (end) => {
    cb('c', 'd', data => {
        end();

        console.log(timer.get('function cb()'));
    });
});
timer.measure('promise', new Promise((resolve, reject) => {
    setTimeout(() => {
        resolve('promise -> resolved');
    }, 200);
})).then(data => {
    console.log(timer.get('promise'));
}).catch(error => {
    console.log(timer.get('promise'));
});
timer.start('measure');
// Some code
timer.end('measure');

Get all measures

timer.get(); // Map
timer.get().toObject() // Object

FAQs

Package last updated on 11 Oct 2016

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc