Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Very simple but powerful nodejs and browser module build to track execution time with a resolution of nanoseconds.
Simply run:
npm install exectimer
const t = require('exectimer');
const Tick = t.Tick;
const promises = [];
for(var i = 0; i < 10; i++) {
const functionExecution = Tick.wrap(function* myFunction() {
yield Promise.resolve(true);
});
promises.push(functionExecution);
}
// After all ticks are finished
Promise.all(promises).then(() => {
// display the results
var results = t.timers.myFunction;
console.log(results.parse(results.duration())); // total duration of all ticks
console.log(results.parse(results.min())); // minimal tick duration
console.log(results.parse(results.max())); // maximal tick duration
console.log(results.parse(results.mean())); // mean tick duration
console.log(results.parse(results.median())); // median tick duration
});
const t = require('exectimer');
const Tick = t.Tick;
for(var i = 0; i < 10; i++) {
Tick.wrap(function myFunction(done) {
setTimeout(function() {
done();
}, 10);
});
}
// Display the results
var results = t.timers.myFunction;
setTimeout(() => {
console.log(results.parse(
results.duration()
)); // total duration of all ticks
console.log(results.parse(
results.min()
)); // minimal tick duration
console.log(results.parse(
results.max()
)); // maximal tick duration
console.log(results.parse(
results.mean()
)); // mean tick duration
console.log(results.parse(
results.median()
)); // median tick duration
}, 101);
const t = require('exectimer');
const Tick = t.Tick;
for(var i = 0; i < 10; i++) {
// unique contexts to avoid aliasing (#9)
(function () {
var tick = new Tick("myFunction");
tick.start();
setTimeout(function() {
tick.stop();
}, Math.random() * 10);
})();
}
// Display the results
var results = t.timers.myFunction;
setTimeout(() => {
console.log(results.parse(
results.duration()
)); // total duration of all ticks
console.log(results.parse(
results.min()
)); // minimal tick duration
console.log(results.parse(
results.max()
)); // maximal tick duration
console.log(results.parse(
results.mean()
)); // mean tick duration
console.log(results.parse(
results.median()
)); // median tick duration
}, 101);
A tick is used to measure the difference between two execution points. All ticks are than used to calculate the average, median, min, max etc. Takes the name of the timer as an argument.
Arguments
name
] (String) Name of the functioncallback
(Function) Function for which to calculate the durationdone
] (Function) Should be passed if function is asynchronousStatic function that takes a name and a function as arguments. If the name is omitted than it tries to read the name of the function or it just uses "anon".
If done
function is not requested than it presumes that the call is synchronous.
It also accepts a generator function in which case done
function is not necessary.
Starts the timer of this tick.
Stops the timer of this tick.
###Timers Array of timers. Each timer has methods to calculate the various metrics. When a tick is created, it is pushed into the timer with name that was passed to the ticker in the constructor.
var tick = new t.Tick("TIMER");
tick.start();
// Do some processing
tick.stop();
var myTimer = t.timers.TIMER;
console.log("It took: " + myTimer.duration());
You can name your timer however you want.
Get the shortest tick.
Get the longest tick.
Get the average tick.
Get the median tick.
Get the total duration of all ticks.
Get the number of ticks.
Parse the output of the previous methods from nanoseconds to us, ms, ns or seconds.
FAQs
Very simple module to calculate block execution time.
The npm package exectimer receives a total of 7,359 weekly downloads. As such, exectimer popularity was classified as popular.
We found that exectimer 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
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.