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

time-logger

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

time-logger

Utility library for tracking and tallying function calls in browsers, Node, or Arangodb's Foxx

Source
npmnpm
Version
0.2.0
Version published
Maintainers
1
Created
Source

time-logger

npm version

Utility library for tracking and tallying function calls in javascript

Use

// in node
const TimeLogger = require('time-logger')

TimeLogger.start('timing-label')
// ... code that needs to be profiled
TimeLogger.end('timing-label')
TimeLogger.dump('timing-label')
TimeLogger.clear('timing-label')

The above will print out the average, min, max, and call count of the code wrapped by timing-label in the following format:

timing-label         calls: 2        avg: 1532.5ms                  min: 1416ms                    max: 1649ms

Calling dump() and clear() with no arguments will print and clear all accumulated timing metrics

Custom Logging

// override the log function
TimeLogger.log = (key, details) => console.log(key, details)

// log function gets called with data to dump
TimeLogger.dump('time-label')

A custom logging function can be added to transform or conditionally log the dumped timing data. The avg, tally, min, and max are available in the details object.

Precision

The most precise timing measurements available are used depending on the platform. In browsers, performance.now() is used to get timing data, in Node process.hrtime() is used, and in Arangodb's Foxx require('internal').time is used.

When a precision timing function is unavailable, Date.now() is used, which gives coarse, millisecond precision.

Keywords

performance

FAQs

Package last updated on 23 Dec 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