Add gulp benchmark task

This commit is contained in:
Calixte Denizet
2026-10-15 14:54:53 +02:00
parent 0252c1f6c9
commit fd3bfaaf1f
2 changed files with 42 additions and 0 deletions
+13
View File
@@ -176,6 +176,19 @@ types can be told apart:
| `integration_tests.yml` | `integrationtest` | `integrationtest` |
| `coverage_browser_tests.yml` | `botbrowsertest` | `browsertest` |
## Benchmarks
Run the benchmarks in `test/benchmarks/` locally:
$ npx gulp benchmark
To compare with `master`:
$ git checkout master
$ npx gulp benchmark --output-json build/bench-master.json
$ git checkout my-branch
$ npx gulp benchmark --compare build/bench-master.json
## Using PDF.js in a web application
To use PDF.js in a web application you can choose to use a pre-built version of the library
+29
View File
@@ -2802,6 +2802,35 @@ gulp.task(
)
);
gulp.task("benchmark", function (done) {
console.log("\n### Running benchmarks");
const args = [
"node_modules/vitest/vitest.mjs",
"bench",
"--run",
"--config",
"test/benchmarks/vitest.config.mjs",
];
const outputJson = getArgValue("--output-json");
if (outputJson) {
args.push("--outputJson", outputJson);
}
const compare = getArgValue("--compare");
if (compare) {
args.push("--compare", compare);
}
const benchProcess = startNode(args, { stdio: "inherit" });
benchProcess.on("close", function (code) {
if (code !== 0) {
done(new Error("Benchmarks failed."));
return;
}
done();
});
});
gulp.task("lint-licenses", function (done) {
console.log("\n### Checking license headers");