| author | |
| committer | |
| log | 77bb2dc094bfe9fff9208a8af94d0da617bdae13 |
| tree | ee8d05c4b0e890da62c2a12f4f94b26790377e31 |
| parent | 41c6cc9001a1a95ea6471c86a1ff4b59890de115 |
3 files changed, 7 insertions(+), 19 deletions(-)
lib/std/crypto/benchmark.zig+3-15| ... | ... | @@ -123,15 +123,6 @@ fn mode(comptime x: comptime_int) comptime_int { |
| 123 | 123 | return if (builtin.mode == .Debug) x / 64 else x; |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | // TODO(#1358): Replace with builtin formatted padding when available. | |
| 127 | fn printPad(stdout: var, s: []const u8) !void { | |
| 128 | var i: usize = 0; | |
| 129 | while (i < 12 - s.len) : (i += 1) { | |
| 130 | try stdout.print(" ", .{}); | |
| 131 | } | |
| 132 | try stdout.print("{}", .{s}); | |
| 133 | } | |
| 134 | ||
| 135 | 126 | pub fn main() !void { |
| 136 | 127 | const stdout = std.io.getStdOut().outStream(); |
| 137 | 128 | |
| ... | ... | @@ -175,24 +166,21 @@ pub fn main() !void { |
| 175 | 166 | inline for (hashes) |H| { |
| 176 | 167 | if (filter == null or std.mem.indexOf(u8, H.name, filter.?) != null) { |
| 177 | 168 | const throughput = try benchmarkHash(H.ty, mode(32 * MiB)); |
| 178 | try printPad(stdout, H.name); | |
| 179 | try stdout.print(": {} MiB/s\n", .{throughput / (1 * MiB)}); | |
| 169 | try stdout.print("{:>11}: {:5} MiB/s\n", .{H.name, throughput / (1 * MiB)}); | |
| 180 | 170 | } |
| 181 | 171 | } |
| 182 | 172 | |
| 183 | 173 | inline for (macs) |M| { |
| 184 | 174 | if (filter == null or std.mem.indexOf(u8, M.name, filter.?) != null) { |
| 185 | 175 | const throughput = try benchmarkMac(M.ty, mode(128 * MiB)); |
| 186 | try printPad(stdout, M.name); | |
| 187 | try stdout.print(": {} MiB/s\n", .{throughput / (1 * MiB)}); | |
| 176 | try stdout.print("{:>11}: {:5} MiB/s\n", .{M.name, throughput / (1 * MiB)}); | |
| 188 | 177 | } |
| 189 | 178 | } |
| 190 | 179 | |
| 191 | 180 | inline for (exchanges) |E| { |
| 192 | 181 | if (filter == null or std.mem.indexOf(u8, E.name, filter.?) != null) { |
| 193 | 182 | const throughput = try benchmarkKeyExchange(E.ty, mode(1000)); |
| 194 | try printPad(stdout, E.name); | |
| 195 | try stdout.print(": {} exchanges/s\n", .{throughput}); | |
| 183 | try stdout.print("{:>11}: {:5} exchanges/s\n", .{E.name, throughput}); | |
| 196 | 184 | } |
| 197 | 185 | } |
| 198 | 186 | } |
lib/std/hash/benchmark.zig+3-3| ... | ... | @@ -172,7 +172,7 @@ fn mode(comptime x: comptime_int) comptime_int { |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | pub fn main() !void { |
| 175 | const stdout = std.io.getStdOut().outStream(); | |
| 175 | const stdout = std.io.getStdOut().writer(); | |
| 176 | 176 | |
| 177 | 177 | var buffer: [1024]u8 = undefined; |
| 178 | 178 | var fixed = std.heap.FixedBufferAllocator.init(buffer[0..]); |
| ... | ... | @@ -248,13 +248,13 @@ pub fn main() !void { |
| 248 | 248 | if (H.has_iterative_api) { |
| 249 | 249 | prng.seed(seed); |
| 250 | 250 | const result = try benchmarkHash(H, count); |
| 251 | try stdout.print(" iterative: {:4} MiB/s [{x:0<16}]\n", .{ result.throughput / (1 * MiB), result.hash }); | |
| 251 | try stdout.print(" iterative: {:5} MiB/s [{x:0<16}]\n", .{ result.throughput / (1 * MiB), result.hash }); | |
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | if (!test_iterative_only) { |
| 255 | 255 | prng.seed(seed); |
| 256 | 256 | const result_small = try benchmarkHashSmallKeys(H, key_size, count); |
| 257 | try stdout.print(" small keys: {:4} MiB/s [{x:0<16}]\n", .{ result_small.throughput / (1 * MiB), result_small.hash }); | |
| 257 | try stdout.print(" small keys: {:5} MiB/s [{x:0<16}]\n", .{ result_small.throughput / (1 * MiB), result_small.hash }); | |
| 258 | 258 | } |
| 259 | 259 | } |
| 260 | 260 | } |
test/standalone/guess_number/main.zig+1-1| ... | ... | @@ -4,7 +4,7 @@ const io = std.io; |
| 4 | 4 | const fmt = std.fmt; |
| 5 | 5 | |
| 6 | 6 | pub fn main() !void { |
| 7 | const stdout = io.getStdOut().outStream(); | |
| 7 | const stdout = io.getStdOut().writer(); | |
| 8 | 8 | const stdin = io.getStdIn(); |
| 9 | 9 | |
| 10 | 10 | try stdout.print("Welcome to the Guess Number Game in Zig.\n", .{}); |