-
Notifications
You must be signed in to change notification settings - Fork 781
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test: Add benchmark for
QUnit.equiv()
Ref #1327.
- Loading branch information
Showing
13 changed files
with
662 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Benchmark for QUnit internals | ||
|
||
## Usage | ||
|
||
The default is to benchmark the local development version of QUnit. | ||
|
||
1. Install QUnit for development and generate the release artefact: | ||
* `qunit$ npm ci` | ||
* `qunit$ npm run build` | ||
2. Link benchmark to local artefact. | ||
NOTE: Alternatively, you can edit benchmark/package.json | ||
and change `file:../..` to something like `2.19.1` to | ||
benchmark older versions of QUnit. | ||
* `qunit/test/benchmark$ npm install` | ||
3. Run the benchmark | ||
* In Node.js: | ||
`qunit/test/benchmark$ node index-node.js` | ||
* In a browser: | ||
* Start a static web server, e.g. using Python | ||
`qunit$ python3 -m http.server 4000` | ||
or PHP: | ||
`php -S localhost:4000` | ||
* Open <http://localhost:4000/test/benchmark/index-browser.html> | ||
* Check the console output. | ||
|
||
Powered by [Benchmark.js](https://benchmarkjs.com/). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* global require, globalThis, QUnitFixtureEquiv, QUnit, console */ | ||
|
||
const Benchmark = typeof require === 'function' ? require('benchmark') : globalThis.Benchmark; | ||
const suite = new Benchmark.Suite(); | ||
|
||
// Check for correctness first, mainly for the return value, | ||
// but also for any unexpected exceptions as Benchmark will tolerate | ||
// uncaught exceptions as being benchmarkable behaviour. | ||
for (const group of QUnitFixtureEquiv) { | ||
group.pairs.forEach((pair, i) => { | ||
const res = QUnit.equiv(pair.a, pair.b); | ||
if (res !== pair.equal) { | ||
throw new Error(`Unexpected return value in "${group.name}" at pairs[${i}]\n Expected: ${pair.equal}\n Actual: ${res}`); | ||
} | ||
}); | ||
} | ||
|
||
suite.add('equiv', function () { | ||
for (const group of QUnitFixtureEquiv) { | ||
for (const pair of group.pairs) { | ||
QUnit.equiv(pair.a, pair.b); | ||
} | ||
} | ||
}); | ||
|
||
for (const group of QUnitFixtureEquiv) { | ||
suite.add(`equiv (${group.name})`, function () { | ||
for (const pair of group.pairs) { | ||
QUnit.equiv(pair.a, pair.b); | ||
} | ||
}); | ||
} | ||
|
||
console.log('Running benchmark...'); | ||
suite.on('cycle', function (event) { | ||
console.log(String(event.target)); | ||
}); | ||
suite.on('complete', function () { | ||
console.log('Done!'); | ||
}); | ||
suite.run({ async: true }); |
Oops, something went wrong.