feat: Add benchmarking
This commit is contained in:
parent
798cbcc6a3
commit
92ec7569b1
3 changed files with 17 additions and 0 deletions
|
@ -18,6 +18,9 @@ pub fn build(b: *std.Build) void {
|
|||
const clap_dep = b.dependency("clap", .{ .target = target, .optimize = optimize });
|
||||
const clap = clap_dep.module("clap");
|
||||
|
||||
const benchmark_dep = b.dependency("benchmark", .{ .target = target, .optimize = optimize });
|
||||
const benchmark = benchmark_dep.module("benchmark");
|
||||
|
||||
var opt = b.addOptions();
|
||||
opt.addOption([]const u8, "version", "0.0.2");
|
||||
const exe = b.addExecutable(.{
|
||||
|
@ -30,6 +33,7 @@ pub fn build(b: *std.Build) void {
|
|||
});
|
||||
exe.addModule("build_info", opt.createModule());
|
||||
exe.addModule("clap", clap);
|
||||
exe.addModule("benchmark", benchmark);
|
||||
|
||||
// This declares intent for the executable to be installed into the
|
||||
// standard location when the user invokes the "install" step (the default
|
||||
|
|
|
@ -5,6 +5,10 @@
|
|||
.clap = .{
|
||||
.url = "https://github.com/Hejsil/zig-clap/archive/refs/tags/0.7.0.tar.gz",
|
||||
.hash = "1220f48518ce22882e102255ed3bcdb7aeeb4891f50b2cdd3bd74b5b2e24d3149ba2"
|
||||
},
|
||||
.benchmark = .{
|
||||
.url = "https://github.com/karlseguin/benchmark.zig/archive/master/latest.tar.gz",
|
||||
.hash = "12201c5d5325df8789a66fb2f014af9e1d4af9edb9ee245bebb4a5435fe01e56d1a2"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
const std = @import("std");
|
||||
const clap = @import("clap");
|
||||
const build_info = @import("build_info");
|
||||
const benchmark = @import("benchmark");
|
||||
const base64 = std.base64;
|
||||
const debug = std.debug;
|
||||
const io = std.io;
|
||||
|
@ -8,6 +9,7 @@ const io = std.io;
|
|||
pub fn main() !void {
|
||||
const params = comptime clap.parseParamsComptime(
|
||||
\\-h, --help Display this help and exit.
|
||||
\\-b, --benchmark Benchmark b64
|
||||
\\-d, --decode Decode base64 to string.
|
||||
\\-e, --encode Encode string to base64.
|
||||
\\-v, --version Display version.
|
||||
|
@ -37,6 +39,13 @@ pub fn main() !void {
|
|||
return;
|
||||
}
|
||||
|
||||
if (res.args.benchmark != 0) {
|
||||
(try benchmark.run(benchmark_encode)).print("b64_encode");
|
||||
(try benchmark.run(benchmark_decode)).print("b64_decode");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (res.args.version != 0) {
|
||||
version();
|
||||
|
||||
|
|
Loading…
Reference in a new issue