Skip to content

Google Benchmark built with the Zig build system

License

Notifications You must be signed in to change notification settings

allyourcodebase/benchmark

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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(googletest_dep.artifact("benchmark"));
// Unless you define your an entry point (i.e. `BENCHMARK_MAIN()`), you need `benchmark_main` too.
benchmarks_exe.linkLibrary(googletest_dep.artifact("benchmark_main"));

About

Google Benchmark built with the Zig build system

Resources

License

Stars

Watchers

Forks