
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
cpuprofile-filter
Advanced tools
v1.1.0
via Nic Jansma http://nicj.net
Licensed under the MIT license
Takes a .cpuprofile
and determines the amount of time that was spent in or under
(inclusive) a configurable list of source files.
As an example use case, cpuprofile-filter
can be used to determine how much
work a first- or third-party library is doing during page load.
Releases are available for download from GitHub.
cpuprofile-filter
is available as the npm cpuprofile-filter module. You can install it
using Node Package Manager (npm):
npm install cpuprofile-filter
Given a .cpuprofile
input (JSON), cpuprofile-filter
will analyze all of the stacks
in the profile and calculate statistics such as how long the profile was captured for,
total CPU time, idle CPU time, and the inclusive CPU time that was spent in the list of target files.
// import
var CpuProfileFilter = require("cpuprofile-filter");
// filter a profile
var results = CpuProfileFilter.filter(profile, config);
// filtered CPU time
var time = results.cpuTimeFiltered;
For example, you could specify a configuration of:
CpuProfileFilter.filter(profile, {
"files": [
"a.js"
]
});
And cpuprofile-filter
will return the amount of time (in microseconds) that
were spent in any function of a.js
, and, any work done (in any other function
or file) triggered by a function in a.js
.
cpuprofile-filter
can optionally be given a list of functions to ignore.
For example, you could specify that you want to track anything in a.js
except
for calls to wrapper()
in a.js
:
CpuProfileFilter.filter(profile, {
"files": [
"a.js"
],
"ignore": [
{
"functionName": "wrapper"
}
]
});
For the above example, note that as long as there is a second or more
function in a.js
besides wrapper()
on the call stack, the sample will still be counted.
CpuProfileFilter.filter(profile, config)
Filters a .cpuprofile
against the given config
Arguments:
profile
: .cpuprofile
data (in JSON)config
config.files
: A list of file names to filterconfig.ignore
: A list of ignoresconfig.ignore.functionName
: A function name to ignoreReturns: An object with the following properties
{
startTime: 1000, // start time (microseconds)
endTime: 2000, // end time (microseconds)
duration: 1000, // duration (microseconds)
sampleCount: 10, // number of samples
timePerSample: 100, // time per sample (microseconds)
cpuTime: 1000, // CPU time of the entire profile (including Program and Garbage time) (microseconds)
cpuTimeFiltered: 500, // CPU time of the filtered functions (microseconds)
idleTime: 0 // Idle time (microseconds)
programTime: 0 // Program (Chrome native) time (microseconds)
garbageTime: 0 // Garbage Collector time (microseconds)
}
Tests are provided in the test/
directory, and can be run via mocha
:
mocha test/*
Or via gulp
:
gulp test
programTime
and garbageTime
fieldsFAQs
.cpuprofile filter
We found that cpuprofile-filter 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.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.