Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
node-perf-timer
Advanced tools
Measuring elapsed time in Node, made simple.
Node's native timing function – process.hrtime()
– is extremely precise, but low-level and messy to use for profiling without any abstraction on top of it.
node-perf-timer
aims to provide a simple API to provide a more intuitive developer experience when measuring elapsed time in Node applications.
npm i --save-dev node-perf-timer
or
yarn add node-perf-timer --dev
const perfTimer = require('node-perf-timer')
// start a timer
perfTimer.start();
functionToBeMeasured();
// returns diff in nanoseconds & logs (by default):
// Message: functionToBeMeasured()
// Duration: 0 s, 3.589862 ms
const nsDiff = perfTimer.stopAndDiff('functionToBeMeasured()');
By default, the configuration object takes the following shape:
const opts = {
shouldPrint: true, // should diffs be logged to the console?
precision: undefined, // e.g. `4`; how many decimal places to use for millisecond formatting
defaultMessage: undefined, // e.g. `"hello bottleneck!"`; default message for each diff being logged
};
config(configObj)
- Adjust default opts for all future perfTimer
calls.start()
- Starts a new timer and returns the absolute start time in nanoseconds.stop()
- Stops the current timer and returns the absolute end time in nanoseconds.diff(nsStartTime, nsEndTime)
- Accepts a start & end time in nanoseconds and returns the difference.stopAndDiff(message?)
- Combines stop() & diff(). If opts.shouldPrint
is set, the diff is logged to the console with message
, opts.defaultMessage
or simply the duration.stopAndRestart()
- Stops timer, starts a new one and returns the nanosecond diff of the stopped timer.Examples for a number of common use cases can be found here (WIP).
MIT
FAQs
Unknown package
The npm package node-perf-timer receives a total of 68 weekly downloads. As such, node-perf-timer popularity was classified as not popular.
We found that node-perf-timer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.