Just to clarify, you can also use zig run -OReleaseFast <filename>
to compile and run your program in release mode. The default optimization mode (for both zig run
and zig build-exe
) is Debug
, which is best for development (safety checks enabled, debug info available, few optimizations applied so it’s easier to step through the code in a debugger), but not a good choice for benchmarking.
Of course, if you want to do benchmarking at an executable level, it’s still best to precompile an executable using zig build-exe
and use something like poop to get nice timing, memory usage, and other stats using two different commands (e.g. add a command-line option in your benchmarking program to select which approach should be executed).