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.
karma-benchmark
Advanced tools
Continuous JavaScript Performance Monitoring with Benchmark.js and the Karma Runner
A Karma plugin to run Benchmark.js over multiple browsers with Jenkins CI compatible output.
npm install karma-benchmark --save-dev
module.exports = function(config) {
config.set({
// Everything discussed below goes in here.
// Other values such as browsers, files, autoWatch, reporters etc.
// are needed as normal, but have been left out of these example.
});
};
In the options object supplied to config.set(), add benchmark
to the list of frameworks in karma.conf.js.
frameworks: ['benchmark']
If you'd like to feed your data into Jenkins, install the jUnit reporter.
npm install karma-junit-reporter --save-dev
Then add to the options object supplied to config.set(), the junitReporter
configuration with the path you want the output xml to be written to.
junitReporter: {
suite: 'unit',
outputFile: 'build/junit-benchmark-results.xml'
}
As large suites of Benchmarks take a long time to run, you may need to increase Karma's timeout from it's default of 60000.
captureTimeout: 60000
Benchmarks can be written as normal using the var suite = new Benchmark.Suite;
format detailed at benchmarkjs.com or with an optional wrapper provided for Benchmark.js that offers a coding style familiar to users of Jasmine and Mocha.
benchmark('_.each', function () {
when('iterating over an array', function () {
_.each([1, 2, 3], function(el){
return el;
});
});
when('iterating over an object', function () {
_.each({one : 1, two : 2, three : 3}, function(el){
return el;
});
});
});
The equivalent of the above _.each when iterating over an array
benchmark with setup and teardown methods is as follows.
benchmark('_.each', function () {
when('iterating over an array', {
before: function() {
this.list = [5, 4, 3];
},
run: function() {
_.each(this.list, function(el) {
return el * Math.random();
});
},
after: function() {
this.list = null;
}
});
});
FAQs
Run Benchmark.js over multiple Browsers, with CI compatible output
The npm package karma-benchmark receives a total of 4,864 weekly downloads. As such, karma-benchmark popularity was classified as popular.
We found that karma-benchmark 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.