Added test runner and better table print in benchmark
This commit is contained in:
+9
-5
@@ -749,8 +749,8 @@ test "Comprehensive Benchmark: All Ops × All Types" {
|
||||
\\
|
||||
, .{ ITERS, SAMPLES });
|
||||
|
||||
const Types = .{ i16, i32, i64, i128, f32, f64 };
|
||||
const TNames = .{ "i16", "i32", "i64", "i128", "f32", "f64" };
|
||||
const Types = .{ i16, i32, i64, i128, i256, f32, f64, f128 };
|
||||
const TNames = .{ "i16", "i32", "i64", "i128", "i256", "f32", "f64", "f128" };
|
||||
const Ops = .{ "add", "sub", "mulBy", "divBy", "scale", "to" };
|
||||
|
||||
var results_matrix: [Ops.len][Types.len]f64 = undefined;
|
||||
@@ -805,11 +805,13 @@ test "Comprehensive Benchmark: All Ops × All Types" {
|
||||
// Median Summary Table
|
||||
std.debug.print("└───────────────────┴──────┴─────────────────────┴─────────────────────┘\n\n", .{});
|
||||
std.debug.print("Median Summary (ns/op):\n", .{});
|
||||
std.debug.print("Operation │ i16 │ i32 │ i64 │ i128 │ f32 │ f64 \n", .{});
|
||||
std.debug.print("───────────────┼───────┼───────┼───────┼───────┼───────┼───────\n", .{});
|
||||
|
||||
std.debug.print("┌──────────────┬───────┬───────┬───────┬───────┬───────┬───────┬───────┬───────┐\n", .{});
|
||||
std.debug.print("│ Operation │ i16 │ i32 │ i64 │ i128 │ i256 │ f32 │ f64 │ f128 │\n", .{});
|
||||
std.debug.print("├──────────────┼───────┼───────┼───────┼───────┼───────┼───────┼───────┼───────┤\n", .{});
|
||||
|
||||
inline for (Ops, 0..) |op_name, oidx| {
|
||||
std.debug.print("{s:<14} │", .{op_name});
|
||||
std.debug.print("│ {s:<11} │", .{op_name});
|
||||
var i: usize = 0;
|
||||
while (i < Types.len) : (i += 1) {
|
||||
std.debug.print("{d:>6.1} │", .{results_matrix[oidx][i]});
|
||||
@@ -817,6 +819,8 @@ test "Comprehensive Benchmark: All Ops × All Types" {
|
||||
std.debug.print("\n", .{});
|
||||
}
|
||||
|
||||
std.debug.print("└──────────────┴───────┴───────┴───────┴───────┴───────┴───────┴───────┴───────┘\n", .{});
|
||||
|
||||
std.debug.print("\nAnti-optimisation sink: {d:.4}\n", .{gsink});
|
||||
try std.testing.expect(gsink != 0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user