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_dep = b.dependency("clap", .{ .target = target, .optimize = optimize });
|
||||||
const clap = clap_dep.module("clap");
|
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();
|
var opt = b.addOptions();
|
||||||
opt.addOption([]const u8, "version", "0.0.2");
|
opt.addOption([]const u8, "version", "0.0.2");
|
||||||
const exe = b.addExecutable(.{
|
const exe = b.addExecutable(.{
|
||||||
|
@ -30,6 +33,7 @@ pub fn build(b: *std.Build) void {
|
||||||
});
|
});
|
||||||
exe.addModule("build_info", opt.createModule());
|
exe.addModule("build_info", opt.createModule());
|
||||||
exe.addModule("clap", clap);
|
exe.addModule("clap", clap);
|
||||||
|
exe.addModule("benchmark", benchmark);
|
||||||
|
|
||||||
// This declares intent for the executable to be installed into the
|
// This declares intent for the executable to be installed into the
|
||||||
// standard location when the user invokes the "install" step (the default
|
// standard location when the user invokes the "install" step (the default
|
||||||
|
|
|
@ -5,6 +5,10 @@
|
||||||
.clap = .{
|
.clap = .{
|
||||||
.url = "https://github.com/Hejsil/zig-clap/archive/refs/tags/0.7.0.tar.gz",
|
.url = "https://github.com/Hejsil/zig-clap/archive/refs/tags/0.7.0.tar.gz",
|
||||||
.hash = "1220f48518ce22882e102255ed3bcdb7aeeb4891f50b2cdd3bd74b5b2e24d3149ba2"
|
.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 std = @import("std");
|
||||||
const clap = @import("clap");
|
const clap = @import("clap");
|
||||||
const build_info = @import("build_info");
|
const build_info = @import("build_info");
|
||||||
|
const benchmark = @import("benchmark");
|
||||||
const base64 = std.base64;
|
const base64 = std.base64;
|
||||||
const debug = std.debug;
|
const debug = std.debug;
|
||||||
const io = std.io;
|
const io = std.io;
|
||||||
|
@ -8,6 +9,7 @@ const io = std.io;
|
||||||
pub fn main() !void {
|
pub fn main() !void {
|
||||||
const params = comptime clap.parseParamsComptime(
|
const params = comptime clap.parseParamsComptime(
|
||||||
\\-h, --help Display this help and exit.
|
\\-h, --help Display this help and exit.
|
||||||
|
\\-b, --benchmark Benchmark b64
|
||||||
\\-d, --decode Decode base64 to string.
|
\\-d, --decode Decode base64 to string.
|
||||||
\\-e, --encode Encode string to base64.
|
\\-e, --encode Encode string to base64.
|
||||||
\\-v, --version Display version.
|
\\-v, --version Display version.
|
||||||
|
@ -37,6 +39,13 @@ pub fn main() !void {
|
||||||
return;
|
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) {
|
if (res.args.version != 0) {
|
||||||
version();
|
version();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue