![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Node.js benchmark runner, modelled after Mocha
and bencha
, based on Benchmark.js.
$ npm i benchr [-g]
Run the benchr
script and provide it with files containing benchmarks:
$ benchr benchmarks/**/*.js
$ benchr benchmarks/suite1.js benchmarks/suite2.js benchmarks/suite3.js
$ benchr -h
benchr – benchmark runner
Usage:
benchr [options] <file>...
Options:
-h --help Show this screen
-V --version Show version
-d --delay=<s> Delay between test cycles, in seconds [default: 0]
-M --min-time=<s> Minimum run time per test cycle, in seconds [default: 0]
-m --max-time=<s> Maximum run time per test cycle, in seconds [default: 5]
-g --grep=<s> Only run suites matching pattern
-R --reporter=<name/file> Reporter to use, either a file path or built-in (`console` or `json`) [default: console]
-r --require=<module> `require()` a module before starting (for instance, `babel-register`)
-p --progress Show progress (depending on reporter)
-P --pretty-print Pretty-print output (depending on reporter)
-v --verbose More verbose output (depending on reporter)
A benchmark file declares one or more suites, each with one or more benchmarks to run.
suite(NAME[, OPTIONS], FN);
benchmark(NAME[, OPTIONS], FN);
Calling suite()
is optional.
suite('Finding a substring', () => {
benchmark('RegExp#test', () => {
/o/.test('Hello World!');
});
benchmark('String#indexOf', () => {
'Hello World!'.indexOf('o') > -1;
});
benchmark('String#match', () => {
!!'Hello World!'.match(/o/);
});
});
(taken from the example on the Benchmark.js website)
Return a promise from a benchmark function and it will be tested asynchronously:
suite('Timeouts', () => {
benchmark('100ms', () => {
return new Promise((resolve) => {
setTimeout(resolve, 100);
});
});
benchmark('200ms', () => {
return new Promise((resolve) => {
setTimeout(resolve, 200);
});
});
});
NOTE: to determine if a function under test returns a promise, it is called once before the tests start. If this is undesirable, for instance due to side-effects, set the promises
option for the benchmark or the entire suite:
suite('Timeouts', { promises : true }, () => { ... });
benchmark('100ms', { promises : true }, () => { ... });
If a benchmark takes an argument, it is assumed to be a continuation callback (pass any errors as first argument to abort the test):
suite('Timeouts', () => {
benchmark('100ms', (done) => {
setTimeout(done, 100);
});
benchmark('200ms', (done) => {
setTimeout(done, 200);
});
});
To work around linter errors regarding suite
and benchmark
being undefined, your test files can export a function that would take suite
and benchmark
as its arguments, thereby making the linter happy:
module.exports = (suite, benchmark) => {
suite('My test suite', () => {
benchmark('Bench 1', ...);
benchmark('Bench 2', ...);
...
})
}
const Runner = require('benchr');
const runner = new Runner({
reporter : Function,
grep : String,
delay : Number,
minTime : Number,
maxTime : Number,
progress : Boolean,
prettyPrint : Boolean,
verbose : Boolean,
}, [ "file1.js", "file2.js", ... ]);
All options map to the similarly-named command line options.
A reporter is a CommonJS module that should export a function that gets passed a benchmark runner instance as argument.
This runner instance implements the EventEmitter
interface, and will emit the following events:
run.start
/ run.complete
file.start
/ file.complete
suite.start
/ suite.complete
benchmark.start
/ benchmark.complete
The different parts are explained as follows:
FAQs
Benchmark runner
The npm package benchr receives a total of 113 weekly downloads. As such, benchr popularity was classified as not popular.
We found that benchr 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
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.