Rename test-bench to bench-2, update README with benchmark docs
This commit is contained in:
41
README.md
41
README.md
@@ -69,6 +69,21 @@ const html = try engine.renderTpl(allocator,
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Development
|
||||||
|
|
||||||
|
### Run Tests
|
||||||
|
|
||||||
|
```bash
|
||||||
|
zig build test
|
||||||
|
```
|
||||||
|
|
||||||
|
### Run Benchmarks
|
||||||
|
|
||||||
|
```bash
|
||||||
|
zig build bench # Run rendering benchmarks
|
||||||
|
zig build bench-2 # Run comparison benchmarks
|
||||||
|
```
|
||||||
|
|
||||||
## Template Syntax
|
## Template Syntax
|
||||||
|
|
||||||
```pug
|
```pug
|
||||||
@@ -91,15 +106,29 @@ html
|
|||||||
|
|
||||||
## Benchmarks
|
## Benchmarks
|
||||||
|
|
||||||
2000 iterations on MacBook Air M2:
|
### Rendering Benchmarks (`zig build bench`)
|
||||||
|
|
||||||
|
20,000 iterations on MacBook Air M2:
|
||||||
|
|
||||||
|
| Template | Avg | Renders/sec | Output |
|
||||||
|
|----------|-----|-------------|--------|
|
||||||
|
| Simple | 11.81 us | 84,701 | 155 bytes |
|
||||||
|
| Medium | 21.10 us | 47,404 | 1,211 bytes |
|
||||||
|
| Complex | 33.48 us | 29,872 | 4,852 bytes |
|
||||||
|
|
||||||
|
### Comparison Benchmarks (`zig build bench-2`)
|
||||||
|
|
||||||
|
2,000 iterations vs Pug.js:
|
||||||
|
|
||||||
| Template | Pugz | Pug.js | Speedup |
|
| Template | Pugz | Pug.js | Speedup |
|
||||||
|----------|------|--------|---------|
|
|----------|------|--------|---------|
|
||||||
| simple-0 | 0.6ms | 2ms | 3.4x |
|
| simple-0 | 0.5ms | 2ms | 3.8x |
|
||||||
| simple-1 | 6.9ms | 9ms | 1.3x |
|
| simple-1 | 6.7ms | 9ms | 1.3x |
|
||||||
| simple-2 | 7.7ms | 9ms | 1.2x |
|
| simple-2 | 5.4ms | 9ms | 1.7x |
|
||||||
| if-expression | 6.0ms | 12ms | 2.0x |
|
| if-expression | 4.4ms | 12ms | 2.7x |
|
||||||
| projects-escaped | 9.3ms | 86ms | 9.2x |
|
| projects-escaped | 7.3ms | 86ms | 11.7x |
|
||||||
|
| search-results | 70.6ms | 41ms | 0.6x |
|
||||||
|
| friends | 682.1ms | 110ms | 0.2x |
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ pub fn build(b: *std.Build) void {
|
|||||||
// ─────────────────────────────────────────────────────────────────────────
|
// ─────────────────────────────────────────────────────────────────────────
|
||||||
const bench_tests = b.addTest(.{
|
const bench_tests = b.addTest(.{
|
||||||
.root_module = b.createModule(.{
|
.root_module = b.createModule(.{
|
||||||
.root_source_file = b.path("src/benchmarks/comparison.zig"),
|
.root_source_file = b.path("src/benchmarks/benchmark_2.zig"),
|
||||||
.target = target,
|
.target = target,
|
||||||
.optimize = .ReleaseFast,
|
.optimize = .ReleaseFast,
|
||||||
.imports = &.{
|
.imports = &.{
|
||||||
@@ -148,7 +148,7 @@ pub fn build(b: *std.Build) void {
|
|||||||
|
|
||||||
const run_bench_tests = b.addRunArtifact(bench_tests);
|
const run_bench_tests = b.addRunArtifact(bench_tests);
|
||||||
|
|
||||||
const bench_test_step = b.step("test-bench", "Run comparison benchmarks (template-engine-bench)");
|
const bench_test_step = b.step("bench-2", "Run comparison benchmarks (template-engine-bench)");
|
||||||
bench_test_step.dependOn(&run_bench_tests.step);
|
bench_test_step.dependOn(&run_bench_tests.step);
|
||||||
|
|
||||||
// ─────────────────────────────────────────────────────────────────────────
|
// ─────────────────────────────────────────────────────────────────────────
|
||||||
|
|||||||
Reference in New Issue
Block a user