summaryrefslogtreecommitdiff
path: root/build.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-08-02 23:04:07 -0300
committerGabriel Schneider <[email protected]>2026-08-10 09:17:07 -0300
commitf9faba2c3bda14ef7942fb089d6ce56e914b9109 (patch)
treec8c6fb7bab154ffd8e64b1b90b065b00c3a25251 /build.zig
parentec19caddb60e748115adb562b46d007598dcdb95 (diff)
downloadpardes-f9faba2c3bda14ef7942fb089d6ce56e914b9109.tar.gz
pardes-f9faba2c3bda14ef7942fb089d6ce56e914b9109.zip
add PDF rendering performance harness
Diffstat (limited to 'build.zig')
-rw-r--r--build.zig34
1 files changed, 34 insertions, 0 deletions
diff --git a/build.zig b/build.zig
index 126f86dc..95592c80 100644
--- a/build.zig
+++ b/build.zig
@@ -50,8 +50,11 @@ pub fn build(b: *std.Build) void {
// JavaScript owns the loop and IO; HTML/CSS own rendering.
const web_step = b.step("web", "build the DOM browser shell into zig-out/web (-Dplatform=web -Dtarget=wasm32-freestanding -Ddump=<dump.zon>)");
const mupdf_check = b.step("mupdf-check", "compile, link, render, and search docs/design.pdf with MuPDF");
+ const pdf_bench_step = b.step("pdf-bench", "benchmark real MuPDF page rendering (-- [--json] [--reps N] [--warmup N] [--path FILE] [--page N] [--pages N])");
if (!enable_mupdf)
mupdf_check.dependOn(&b.addFail("mupdf-check is unavailable with -Dmupdf=false").step);
+ if (!enable_mupdf)
+ pdf_bench_step.dependOn(&b.addFail("pdf-bench is unavailable with -Dmupdf=false").step);
// Web LOOK has a tiny read-only source filesystem. Generate one Zig module
// on the host from every tracked .zig path + its current working-tree
@@ -374,6 +377,37 @@ pub fn build(b: *std.Build) void {
.target = target,
.pdf = b.path("docs/design.pdf"),
}));
+
+ // A headless renderer benchmark with its own ReleaseFast wrapper
+ // module. Reusing root_mod's Debug-mode MuPDF import here would
+ // benchmark Zig safety checks around optimized C rather than the
+ // production-cost boundary the scoreboard is meant to expose.
+ const pdf_bench_mod = b.createModule(.{
+ .target = target,
+ .optimize = .ReleaseFast,
+ .root_source_file = b.path("src/pdf.zig"),
+ .link_libc = true,
+ });
+ mupdf.linkTo(pdf_bench_mod);
+ pdf_bench_mod.addIncludePath(b.path("src"));
+ pdf_bench_mod.addCSourceFile(.{
+ .file = b.path("src/pdf_bridge.c"),
+ .flags = &.{"-std=gnu11"},
+ });
+ const pdf_bench = b.addExecutable(.{
+ .name = "pardes-pdf-bench",
+ .root_module = b.createModule(.{
+ .target = target,
+ .optimize = .ReleaseFast,
+ .root_source_file = b.path("test/pdf_bench.zig"),
+ .link_libc = true,
+ }),
+ });
+ pdf_bench.root_module.addImport("mupdf", pdf_bench_mod);
+ const run_pdf_bench = b.addRunArtifact(pdf_bench);
+ if (b.args) |args| run_pdf_bench.addArgs(args);
+ run_pdf_bench.setCwd(b.path("."));
+ pdf_bench_step.dependOn(&run_pdf_bench.step);
}
}