diff options
Diffstat (limited to 'lib/std')
| -rw-r--r-- | lib/std/crypto/benchmark.zig | 18 | ||||
| -rw-r--r-- | lib/std/hash/benchmark.zig | 6 |
2 files changed, 6 insertions, 18 deletions
diff --git a/lib/std/crypto/benchmark.zig b/lib/std/crypto/benchmark.zig index 8f961f80f2..8c5d75f80a 100644 --- a/lib/std/crypto/benchmark.zig +++ b/lib/std/crypto/benchmark.zig @@ -123,15 +123,6 @@ fn mode(comptime x: comptime_int) comptime_int { return if (builtin.mode == .Debug) x / 64 else x; } -// TODO(#1358): Replace with builtin formatted padding when available. -fn printPad(stdout: var, s: []const u8) !void { - var i: usize = 0; - while (i < 12 - s.len) : (i += 1) { - try stdout.print(" ", .{}); - } - try stdout.print("{}", .{s}); -} - pub fn main() !void { const stdout = std.io.getStdOut().outStream(); @@ -175,24 +166,21 @@ pub fn main() !void { inline for (hashes) |H| { if (filter == null or std.mem.indexOf(u8, H.name, filter.?) != null) { const throughput = try benchmarkHash(H.ty, mode(32 * MiB)); - try printPad(stdout, H.name); - try stdout.print(": {} MiB/s\n", .{throughput / (1 * MiB)}); + try stdout.print("{:>11}: {:5} MiB/s\n", .{H.name, throughput / (1 * MiB)}); } } inline for (macs) |M| { if (filter == null or std.mem.indexOf(u8, M.name, filter.?) != null) { const throughput = try benchmarkMac(M.ty, mode(128 * MiB)); - try printPad(stdout, M.name); - try stdout.print(": {} MiB/s\n", .{throughput / (1 * MiB)}); + try stdout.print("{:>11}: {:5} MiB/s\n", .{M.name, throughput / (1 * MiB)}); } } inline for (exchanges) |E| { if (filter == null or std.mem.indexOf(u8, E.name, filter.?) != null) { const throughput = try benchmarkKeyExchange(E.ty, mode(1000)); - try printPad(stdout, E.name); - try stdout.print(": {} exchanges/s\n", .{throughput}); + try stdout.print("{:>11}: {:5} exchanges/s\n", .{E.name, throughput}); } } } diff --git a/lib/std/hash/benchmark.zig b/lib/std/hash/benchmark.zig index 255c98e409..0eb3a25fe1 100644 --- a/lib/std/hash/benchmark.zig +++ b/lib/std/hash/benchmark.zig @@ -172,7 +172,7 @@ fn mode(comptime x: comptime_int) comptime_int { } pub fn main() !void { - const stdout = std.io.getStdOut().outStream(); + const stdout = std.io.getStdOut().writer(); var buffer: [1024]u8 = undefined; var fixed = std.heap.FixedBufferAllocator.init(buffer[0..]); @@ -248,13 +248,13 @@ pub fn main() !void { if (H.has_iterative_api) { prng.seed(seed); const result = try benchmarkHash(H, count); - try stdout.print(" iterative: {:4} MiB/s [{x:0<16}]\n", .{ result.throughput / (1 * MiB), result.hash }); + try stdout.print(" iterative: {:5} MiB/s [{x:0<16}]\n", .{ result.throughput / (1 * MiB), result.hash }); } if (!test_iterative_only) { prng.seed(seed); const result_small = try benchmarkHashSmallKeys(H, key_size, count); - try stdout.print(" small keys: {:4} MiB/s [{x:0<16}]\n", .{ result_small.throughput / (1 * MiB), result_small.hash }); + try stdout.print(" small keys: {:5} MiB/s [{x:0<16}]\n", .{ result_small.throughput / (1 * MiB), result_small.hash }); } } } |
