mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-03-09 18:16:38 +01:00
Remove usages of deprecatedWriter
This commit is contained in:
parent
37ecaae639
commit
de489031d8
6 changed files with 59 additions and 12 deletions
|
|
@ -39,35 +39,44 @@ fn benchmarkCodepointCount(buf: []const u8) !ResultCount {
|
|||
}
|
||||
|
||||
pub fn main() !void {
|
||||
const stdout = std.fs.File.stdout().deprecatedWriter();
|
||||
// Size of buffer is about size of printed message.
|
||||
var stdout_buffer: [0x100]u8 = undefined;
|
||||
var stdout_writer = std.fs.File.stdout().writer(&stdout_buffer);
|
||||
const stdout = &stdout_writer.interface;
|
||||
|
||||
try stdout.print("short ASCII strings\n", .{});
|
||||
try stdout.flush();
|
||||
{
|
||||
const result = try benchmarkCodepointCount("abc");
|
||||
try stdout.print(" count: {:5} MiB/s [{d}]\n", .{ result.throughput / (1 * MiB), result.count });
|
||||
}
|
||||
|
||||
try stdout.print("short Unicode strings\n", .{});
|
||||
try stdout.flush();
|
||||
{
|
||||
const result = try benchmarkCodepointCount("ŌŌŌ");
|
||||
try stdout.print(" count: {:5} MiB/s [{d}]\n", .{ result.throughput / (1 * MiB), result.count });
|
||||
}
|
||||
|
||||
try stdout.print("pure ASCII strings\n", .{});
|
||||
try stdout.flush();
|
||||
{
|
||||
const result = try benchmarkCodepointCount("hello" ** 16);
|
||||
try stdout.print(" count: {:5} MiB/s [{d}]\n", .{ result.throughput / (1 * MiB), result.count });
|
||||
}
|
||||
|
||||
try stdout.print("pure Unicode strings\n", .{});
|
||||
try stdout.flush();
|
||||
{
|
||||
const result = try benchmarkCodepointCount("こんにちは" ** 16);
|
||||
try stdout.print(" count: {:5} MiB/s [{d}]\n", .{ result.throughput / (1 * MiB), result.count });
|
||||
}
|
||||
|
||||
try stdout.print("mixed ASCII/Unicode strings\n", .{});
|
||||
try stdout.flush();
|
||||
{
|
||||
const result = try benchmarkCodepointCount("Hyvää huomenta" ** 16);
|
||||
try stdout.print(" count: {:5} MiB/s [{d}]\n", .{ result.throughput / (1 * MiB), result.count });
|
||||
}
|
||||
try stdout.flush();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue