Socket
Socket
Sign inDemoInstall

fn-exec-stats

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fn-exec-stats

Get execution stats for javascript functions


Version published
Weekly downloads
4
decreased by-33.33%
Maintainers
1
Weekly downloads
 
Created
Source

fn-exec-stats

Get execution stats for javascript functions. This is only intended to debug performance issues, DO NOT USE IN PRODUCTION!

Install

npm install fn-exec-stats or yarn add fn-exec-stats

Usage

const fnWrapper = require('fn-exec-stats'); // or `import fnWrapper from 'fn-exec-stats';`

const wrappedFunction = fnWrapper(Math.random, {
    enabled: false, // defaults to true
});

wrappedFunction.enableExecStats(); // start tracking the executions

// get some random numbers
wrappedFunction();
wrappedFunction();
wrappedFunction();

// log the executions stats
const stats = wrappedFunction.getExecStats();
console.log(stats);

// prints the stats in milliseconds:
// {
//   "executedTimes": 3,
//   "maxTime": 3,
//   "meanTime": 2,
//   "minTime": 1,
//   "totalTime": 6
// }

wrappedFunction.disableExecStats(); // stops tracking the executions

// After disabling the tracking, calling `getExecStats` will return the last stats
// before the tracking was disabled

FAQs

Package last updated on 31 Jul 2018

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