Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
uubench
Advanced tools
Readme
A tiny asynchronous JavaScript benchmarking library
uubench provides a simple harness for measuring the execution time of JavaScript code. Design your experiments, analyze the numbers and present the data as you see fit.
Features:
Set up a benchmark suite:
var suite = new uubench.Suite({
start: function() {
console.log("starting...");
},
result: function(name, stats) {
console.log(name + ": " + stats.iterations/stats.elapsed);
},
done: function() {
console.log("finished");
}
});
Add some benchmarks:
suite.bench("async", function(next) {
myAsyncFunc(function() {
next();
});
});
suite.bench("sync", function(next) {
mySyncFunc();
next();
});
Go man go!
suite.run();
Via npm:
$ npm install uubench
In Node:
var uubench = require('uubench');
In the browser:
<script src="uubench.js"></script>
By design, uubench doesn't come with extras. Instead, you use the low-level API to build your own unique benchmark suites.
uubench ships with the following defaults that apply to every test suite:
uubench.defaults = {
type: "adaptive", // adaptive or fixed
iterations: 10, // starting iterations
min: 100, // minimum run time (ms) - adaptive only
delay: 100 // delay between tests (ms)
}
You may override these globally or per-suite. Read on to find out what each option does.
By default uubench uses adaptive test cycles to allow reasonable execution time across different environments. To use fixed cycles instead, set the type
to "fixed":
var suite = new uubench.Suite({
type: "fixed",
iterations: 1000, // run each benchmark exactly 1000 times
...
});
uubench defaults to a minimum runtime of 100ms in adaptive mode. To adjust this runtime:
var suite = new uubench.Suite({
min: 1000, // each benchmark should run for at least 1000ms
...
});
In adaptive mode it is sometimes useful to bump up the starting iterations to reach the minimum runtime faster:
var suite = new uubench.Suite({
iterations: 1000, // run each benchmark a minimum of 1000 times
...
});
uubench imposes a 100ms delay between benchmarks to give any UI elements that might be present time to update. This delay can be tweaked:
var suite = new uubench.Suite({
delay: 500, // 500ms delay between benchmarks
...
});
To manually loop within a given benchmark, add a second argument to the benchmark's argument list. uubench will then automatically disable auto-looping:
suite.bench("foo", function(next, count) {
while (count--) {
...
}
next();
});
To collect benchmark data over multiple runs, simply rerun the suite on completion:
var suite = new uubench.Suite({
...
done: function() {
if (--runCounter) {
console.log("I'm finished!");
} else {
suite.run();
}
}
});
Beware of relying on multiple in-process runs to establish statistical relevance. Better data can be obtained by completely re-running your test scripts.
Rather than imposing a limited statistical model on benchmark data, uubench gives you the raw numbers. If you want to go nuts with the math have a look at this gist.
In most cases auto looping doesn't add enough overhead to benchmark times to be worth worrying about, but extremely fast benchmarks can suffer. Add a calibration test if you want to correct for this overhead:
suite.bench("calibrate", function(next) {
next();
});
You can then subtract the elapsed time of the "calibrate" test from other tests in the suite.
uubench was inspired by the venerable jslitmus
FAQs
A tiny asynchronous JavaScript benchmarking library
The npm package uubench receives a total of 37 weekly downloads. As such, uubench popularity was classified as not popular.
We found that uubench demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.