Add README and simplify ViewEngine API

- ViewEngine.init() no longer requires allocator
- render() and renderTpl() accept allocator parameter
- Remove deinit() - no resources to clean up
- Remove unused parse/renderDoc methods
- Add memory management guidance to runtime.zig
- Clean up unused imports and options
This commit is contained in:
2026-01-17 23:59:22 +05:30
parent 1fff91d7d9
commit 458de03c02
19 changed files with 1036 additions and 366 deletions

View File

@@ -112,9 +112,12 @@ pub fn build(b: *std.Build) void {
const bench = b.addExecutable(.{
.name = "bench",
.root_module = b.createModule(.{
.root_source_file = b.path("src/benchmark.zig"),
.root_source_file = b.path("src/benchmarks/benchmark.zig"),
.target = target,
.optimize = .ReleaseFast, // Always use ReleaseFast for benchmarks
.imports = &.{
.{ .name = "pugz", .module = mod },
},
}),
});
@@ -126,6 +129,51 @@ pub fn build(b: *std.Build) void {
const bench_step = b.step("bench", "Run rendering benchmarks");
bench_step.dependOn(&run_bench.step);
// ─────────────────────────────────────────────────────────────────────────
// Comparison Benchmark Tests (template-engine-bench templates)
// Run all: zig build test-bench
// Run one: zig build test-bench -- simple-0
// ─────────────────────────────────────────────────────────────────────────
const bench_tests = b.addTest(.{
.root_module = b.createModule(.{
.root_source_file = b.path("src/benchmarks/comparison.zig"),
.target = target,
.optimize = .ReleaseFast,
.imports = &.{
.{ .name = "pugz", .module = mod },
},
}),
.filters = if (b.args) |args| args else &.{},
});
const run_bench_tests = b.addRunArtifact(bench_tests);
const bench_test_step = b.step("test-bench", "Run comparison benchmarks (template-engine-bench)");
bench_test_step.dependOn(&run_bench_tests.step);
// ─────────────────────────────────────────────────────────────────────────
// Profile executable (for CPU profiling)
// ─────────────────────────────────────────────────────────────────────────
const profile = b.addExecutable(.{
.name = "profile",
.root_module = b.createModule(.{
.root_source_file = b.path("src/benchmarks/profile_friends.zig"),
.target = target,
.optimize = .ReleaseFast,
.imports = &.{
.{ .name = "pugz", .module = mod },
},
}),
});
b.installArtifact(profile);
const run_profile = b.addRunArtifact(profile);
run_profile.step.dependOn(b.getInstallStep());
const profile_step = b.step("profile", "Run friends template for profiling");
profile_step.dependOn(&run_profile.step);
// Just like flags, top level steps are also listed in the `--help` menu.
//
// The Zig build system is entirely implemented in userland, which means