diff options
author | 2021-11-20 20:18:57 -0800 | |
---|---|---|
committer | 2021-12-16 19:18:51 -0800 | |
commit | dccc6bf1afc2047a912162020c4c6858a51344af (patch) | |
tree | 9970fcd847c461d0675ba73dddf3fcf39952645d /misctools | |
parent | e331ebbf7de7582b727f28fb4c9a0c5e08c0e326 (diff) | |
download | bun-dccc6bf1afc2047a912162020c4c6858a51344af.tar.gz bun-dccc6bf1afc2047a912162020c4c6858a51344af.tar.zst bun-dccc6bf1afc2047a912162020c4c6858a51344af.zip |
[http_debug] Pretty print
Diffstat (limited to 'misctools')
-rw-r--r-- | misctools/http_bench.zig | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/misctools/http_bench.zig b/misctools/http_bench.zig index 9100d3614..00b061df1 100644 --- a/misctools/http_bench.zig +++ b/misctools/http_bench.zig @@ -215,6 +215,8 @@ pub fn main() anyerror!void { var read_count: usize = 0; var success_count: usize = 0; var fail_count: usize = 0; + var min_duration: usize = std.math.maxInt(usize); + var max_duration: usize = 0; var timer = try std.time.Timer.start(); while (read_count < args.count) { while (channel.tryReadItem() catch null) |http| { @@ -227,7 +229,24 @@ pub fn main() anyerror!void { } else { fail_count += 1; } - Output.printError(" {}\n", .{resp}); + + max_duration = @maximum(max_duration, http.elapsed); + min_duration = @minimum(min_duration, http.elapsed); + + switch (resp.status_code) { + 200, 202, 302 => { + Output.prettyError(" <r><green>{d}<r>", .{resp.status_code}); + }, + else => { + Output.prettyError(" <r><red>{d}<r>", .{resp.status_code}); + }, + } + + Output.prettyError(" <d>{s}<r><d> - {s}<r> <d>({d} bytes)<r>\n", .{ + @tagName(http.client.method), + http.client.url.href, + http.response_buffer.list.items.len, + }); } else if (http.err) |err| { fail_count += 1; Output.printError(" err: {s}\n", .{@errorName(err)}); @@ -239,12 +258,15 @@ pub fn main() anyerror!void { Output.flush(); } } + Output.prettyErrorln("\n<d>------<r>\n\n", .{}); + Output.prettyErrorln("Success: <b><green>{d}<r>\nFailure: <b><red>{d}<r>\n\n", .{ + success_count, + fail_count, + }); Output.printElapsed(@floatCast(f64, @intToFloat(f128, timer.read()) / std.time.ns_per_ms)); - Output.prettyErrorln("Completed {d}\n Success: <green>{d}<r>\n Failure: <red>{d}<r>\n", .{ + Output.prettyErrorln(" {d} requests", .{ read_count, - success_count, - fail_count, }); Output.flush(); } |