Google Benchmark built with the Zig build system
  • Zig 95.4%
  • C++ 4.6%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Francisco Nevitt Gonçalves 52841d1f80 Fix copy pasta typo
2026-11-12 15:57:59 +00:00
.github/workflows Bump to Zig 0.16.0 2026-06-02 11:00:54 +01:00
src Add sample benchmark 2026-02-09 22:50:24 +00:00
.gitignore Bump to Zig 0.16.0 2026-06-02 11:00:54 +01:00
build.zig Bump to Zig 0.16.0 2026-06-02 11:00:54 +01:00
build.zig.zon Bump to Zig 0.16.0 2026-06-02 11:00:54 +01:00
LICENSE Add MIT license 2026-02-09 22:43:07 +00:00
README.md Fix copy pasta typo 2026-11-12 15:57:59 +00:00

Google Benchmark

This is Google Benchmark, packaged for Zig.

How to use it

First, update your build.zig.zon:

zig fetch --save git+https://github.com/allyourcodebase/benchmark

Next, in build.zig, declare the dependency and link your benchmarks with the static libraries:

const benchmark_dep = b.dependency("benchmark", .{
    .target = target,
    .optimize = optimize,
});

const benchmarks_exe = b.addExecutable(.{
    .name = "benchmarks",
    .root_module = b.createModule(.{ .target = target, .optimize = optimize }),
});
benchmarks_exe.addCSourceFiles(.{ .files = &.{"src/bm.cpp"} }); // your benchmark files
benchmarks_exe.linkLibrary(benchmark_dep.artifact("benchmark"));
// Unless you define your an entry point (i.e. `BENCHMARK_MAIN()`), you need `benchmark_main` too.
benchmarks_exe.linkLibrary(benchmark_dep.artifact("benchmark_main"));