diff options
Diffstat (limited to 'build.zig')
| -rw-r--r-- | build.zig | 34 |
1 files changed, 34 insertions, 0 deletions
@@ -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); } } |
