diff --git a/README.md b/README.md index 698334f137100..b255731434c76 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/gulpfile.mjs b/gulpfile.mjs index 9e2ba5a538ca0..c6c3071ead712 100644 --- a/gulpfile.mjs +++ b/gulpfile.mjs @@ -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");