eb81856565
Ship QUALITY_PLAN sessions 31–33: fetchable package index URLs, showcase app and micro/nexus benchmarks, and debugger-friendly C codegen. - Registry: BUX_REGISTRY accepts http(s) URLs (curl/wget → ~/.bux/cache) - E.2: make test-apps smoke for nexus/boko/simpledb/jwt-pitbul - E.5: benches/micro + C/Nim/Zig twins; make bench-nexus (wrk) - E.4: HIR locs → #line .bux; default -O0 -g; --release -O2; make test-dwarf
23 lines
621 B
Zig
23 lines
621 B
Zig
// Zig twin of benches/c/fib.c — recursive fib(30)
|
|
// Build: zig build-exe -OReleaseFast -femit-bin=build/fib fib.zig
|
|
const std = @import("std");
|
|
|
|
fn fib(n: i32) i32 {
|
|
if (n <= 1) return n;
|
|
return fib(n - 1) + fib(n - 2);
|
|
}
|
|
|
|
fn nowUs() i64 {
|
|
return @divTrunc(@as(i64, @intCast(std.time.nanoTimestamp())), 1000);
|
|
}
|
|
|
|
pub fn main() !void {
|
|
_ = fib(20);
|
|
const t0 = nowUs();
|
|
const r = fib(30);
|
|
const t1 = nowUs();
|
|
if (r < 0) return error.Unreachable;
|
|
const out = std.io.getStdOut().writer();
|
|
try out.print("BENCH fib30 iters=1 total_us={d} us_per_op={d}\n", .{ t1 - t0, t1 - t0 });
|
|
}
|