clean up dead code and improve stats

This commit is contained in:
Jeffrey C. Ollie 2024-02-10 20:14:16 -06:00
parent bd361e40ee
commit e0c2a5c95e
Signed by: jeff
GPG key ID: 6F86035A6D97044E

View file

@ -8,43 +8,6 @@ fn signal(_: c_int) callconv(.C) void {
done = true; done = true;
} }
var column: u8 = 0;
var line: u8 = 0;
fn nextColumn() u8 {
const c = column;
column = (column + 7) % 80;
return c + 1;
}
fn nextLine() u8 {
const l = line;
line = (line + 27) % 24;
return l + 1;
}
var red: u8 = 0;
var green: u8 = 0;
var blue: u8 = 0;
inline fn nextRed() u8 {
const r = red;
red +%= 31;
return r;
}
inline fn nextGreen() u8 {
const g = green;
green +%= 43;
return g;
}
inline fn nextBlue() u8 {
const b = blue;
blue +%= 67;
return b;
}
pub fn main() !void { pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){}; var gpa = std.heap.GeneralPurposeAllocator(.{}){};
const alloc = gpa.allocator(); const alloc = gpa.allocator();
@ -160,6 +123,10 @@ pub fn main() !void {
std.debug.print("finished sending data...\n", .{}); std.debug.print("finished sending data...\n", .{});
} }
std.debug.print("time to send data: ", .{});
{
var value = elapsed;
const units = [_]struct { const units = [_]struct {
name: []const u8, name: []const u8,
factor: u64, factor: u64,
@ -177,16 +144,18 @@ pub fn main() !void {
var i: usize = 0; var i: usize = 0;
for (units) |unit| { for (units) |unit| {
if (elapsed > unit.factor) { if (value > unit.factor) {
if (i > 0) std.debug.print(" ", .{}); if (i > 0) std.debug.print(" ", .{});
const r = elapsed % unit.factor; const r = value % unit.factor;
const x = (elapsed - r) / unit.factor; const x = (value - r) / unit.factor;
std.debug.print("{d}{s}", .{ x, unit.name }); std.debug.print("{d}{s}", .{ x, unit.name });
elapsed = r; value = r;
i += 1; i += 1;
} }
} }
}
std.debug.print("\n", .{}); std.debug.print("\n", .{});
std.debug.print("{d}\n", .{written.len}); std.debug.print("bytes written {d}\n", .{written.len});
std.debug.print("{d:>6.2} MiB/s\n", .{(@as(f64, @floatFromInt(written.len)) / (1024.0 * 1024.0)) / (@as(f64, @floatFromInt(elapsed)) / std.time.ns_per_s)});
} }