From 0fe6d1646f68b5b4726c521f52d294a9a70701b1 Mon Sep 17 00:00:00 2001 From: Austin Rude Date: Wed, 15 Dec 2021 12:06:05 -0700 Subject: [PATCH] Use std.debug.print instead of std.debug.warn --- zig-ecs/examples/group_sort.zig | 10 +++++----- zig-ecs/examples/simple.zig | 6 +++--- zig-ecs/examples/view_vs_group.zig | 22 +++++++++++----------- zig-ecs/src/ecs/component_storage.zig | 1 - zig-ecs/src/ecs/sparse_set.zig | 11 +++++------ zig-ecs/src/process/scheduler.zig | 12 ++++++------ zig-ecs/tests/groups_test.zig | 11 +++++------ 7 files changed, 35 insertions(+), 38 deletions(-) diff --git a/zig-ecs/examples/group_sort.zig b/zig-ecs/examples/group_sort.zig index a5c91f1..3097b72 100644 --- a/zig-ecs/examples/group_sort.zig +++ b/zig-ecs/examples/group_sort.zig @@ -32,7 +32,7 @@ fn createEntities(reg: *ecs.Registry) void { } var end = timer.lap(); - std.debug.warn("create {d} entities: {d}\n", .{ total_entities, @intToFloat(f64, end) / 1000000000 }); + std.debug.print("create {d} entities: {d}\n", .{ total_entities, @intToFloat(f64, end) / 1000000000 }); } fn owningGroup(reg: *ecs.Registry) void { @@ -40,7 +40,7 @@ fn owningGroup(reg: *ecs.Registry) void { // var group_iter = group.iterator(struct { vel: *Velocity, pos: *Position }); // while (group_iter.next()) |e| { - // std.debug.warn("pos.y {d:.3}, ent: {}\n", .{e.pos.y, group_iter.entity()}); + // std.debug.print("pos.y {d:.3}, ent: {}\n", .{e.pos.y, group_iter.entity()}); // } const SortContext = struct { @@ -52,15 +52,15 @@ fn owningGroup(reg: *ecs.Registry) void { var timer = std.time.Timer.start() catch unreachable; group.sort(Position, {}, SortContext.sort); var end = timer.lap(); - std.debug.warn("group (sort): {d}\n", .{@intToFloat(f64, end) / 1000000000}); + std.debug.print("group (sort): {d}\n", .{@intToFloat(f64, end) / 1000000000}); timer.reset(); group.sort(Position, {}, SortContext.sort); end = timer.lap(); - std.debug.warn("group (sort 2): {d}\n", .{@intToFloat(f64, end) / 1000000000}); + std.debug.print("group (sort 2): {d}\n", .{@intToFloat(f64, end) / 1000000000}); // var group_iter2 = group.iterator(struct { vel: *Velocity, pos: *Position }); // while (group_iter2.next()) |e| { - // std.debug.warn("pos.y {d:.3}, ent: {}\n", .{e.pos.y, group_iter2.entity()}); + // std.debug.print("pos.y {d:.3}, ent: {}\n", .{e.pos.y, group_iter2.entity()}); // } } diff --git a/zig-ecs/examples/simple.zig b/zig-ecs/examples/simple.zig index 9a559b1..4b973ac 100644 --- a/zig-ecs/examples/simple.zig +++ b/zig-ecs/examples/simple.zig @@ -25,17 +25,17 @@ pub fn main() !void { while (iter.next()) |entity| { var pos = view.get(Position, entity); const vel = view.getConst(Velocity, entity); - std.debug.warn("entity: {}, pos: {d}, vel: {d}\n", .{ entity, pos.*, vel }); + std.debug.print("entity: {}, pos: {d}, vel: {d}\n", .{ entity, pos.*, vel }); pos.*.x += vel.x; pos.*.y += vel.y; } - std.debug.warn("---- resetting iter\n", .{}); + std.debug.print("---- resetting iter\n", .{}); iter.reset(); while (iter.next()) |entity| { const pos = view.getConst(Position, entity); const vel = view.getConst(Velocity, entity); - std.debug.warn("entity: {}, pos: {d}, vel: {d}\n", .{ entity, pos, vel }); + std.debug.print("entity: {}, pos: {d}, vel: {d}\n", .{ entity, pos, vel }); } } diff --git a/zig-ecs/examples/view_vs_group.zig b/zig-ecs/examples/view_vs_group.zig index 4b50f07..d76f48f 100644 --- a/zig-ecs/examples/view_vs_group.zig +++ b/zig-ecs/examples/view_vs_group.zig @@ -30,11 +30,11 @@ fn createEntities(reg: *ecs.Registry) void { } var end = timer.lap(); - std.debug.warn("create entities: \t{d}\n", .{@intToFloat(f64, end) / 1000000000}); + std.debug.print("create entities: \t{d}\n", .{@intToFloat(f64, end) / 1000000000}); } fn iterateView(reg: *ecs.Registry) void { - std.debug.warn("--- multi-view ---\n", .{}); + std.debug.print("--- multi-view ---\n", .{}); var view = reg.view(.{ Velocity, Position }, .{}); var timer = std.time.Timer.start() catch unreachable; @@ -48,15 +48,15 @@ fn iterateView(reg: *ecs.Registry) void { } var end = timer.lap(); - std.debug.warn("view (iter): \t{d}\n", .{@intToFloat(f64, end) / 1000000000}); + std.debug.print("view (iter): \t{d}\n", .{@intToFloat(f64, end) / 1000000000}); } fn nonOwningGroup(reg: *ecs.Registry) void { - std.debug.warn("--- non-owning ---\n", .{}); + std.debug.print("--- non-owning ---\n", .{}); var timer = std.time.Timer.start() catch unreachable; var group = reg.group(.{}, .{ Velocity, Position }, .{}); var end = timer.lap(); - std.debug.warn("group (create): {d}\n", .{@intToFloat(f64, end) / 1000000000}); + std.debug.print("group (create): {d}\n", .{@intToFloat(f64, end) / 1000000000}); timer.reset(); var group_iter = group.iterator(); @@ -69,15 +69,15 @@ fn nonOwningGroup(reg: *ecs.Registry) void { } end = timer.lap(); - std.debug.warn("group (iter): \t{d}\n", .{@intToFloat(f64, end) / 1000000000}); + std.debug.print("group (iter): \t{d}\n", .{@intToFloat(f64, end) / 1000000000}); } fn owningGroup(reg: *ecs.Registry) void { - std.debug.warn("--- owning ---\n", .{}); + std.debug.print("--- owning ---\n", .{}); var timer = std.time.Timer.start() catch unreachable; var group = reg.group(.{ Velocity, Position }, .{}, .{}); var end = timer.lap(); - std.debug.warn("group (create): {d}\n", .{@intToFloat(f64, end) / 1000000000}); + std.debug.print("group (create): {d}\n", .{@intToFloat(f64, end) / 1000000000}); timer.reset(); var group_iter = group.iterator(struct { vel: *Velocity, pos: *Position }); @@ -87,12 +87,12 @@ fn owningGroup(reg: *ecs.Registry) void { } end = timer.lap(); - std.debug.warn("group (iter): \t{d}\n", .{@intToFloat(f64, end) / 1000000000}); + std.debug.print("group (iter): \t{d}\n", .{@intToFloat(f64, end) / 1000000000}); timer.reset(); group.each(each); end = timer.lap(); - std.debug.warn("group (each): \t{d}\n", .{@intToFloat(f64, end) / 1000000000}); + std.debug.print("group (each): \t{d}\n", .{@intToFloat(f64, end) / 1000000000}); timer.reset(); @@ -110,7 +110,7 @@ fn owningGroup(reg: *ecs.Registry) void { } end = timer.lap(); - std.debug.warn("group (direct): {d}\n", .{@intToFloat(f64, end) / 1000000000}); + std.debug.print("group (direct): {d}\n", .{@intToFloat(f64, end) / 1000000000}); } fn each(e: struct { vel: *Velocity, pos: *Position }) void { diff --git a/zig-ecs/src/ecs/component_storage.zig b/zig-ecs/src/ecs/component_storage.zig index c92dbc0..e3aa6b7 100644 --- a/zig-ecs/src/ecs/component_storage.zig +++ b/zig-ecs/src/ecs/component_storage.zig @@ -1,5 +1,4 @@ const std = @import("std"); -const warn = std.debug.warn; const utils = @import("utils.zig"); const SparseSet = @import("sparse_set.zig").SparseSet; diff --git a/zig-ecs/src/ecs/sparse_set.zig b/zig-ecs/src/ecs/sparse_set.zig index e414528..7752d62 100644 --- a/zig-ecs/src/ecs/sparse_set.zig +++ b/zig-ecs/src/ecs/sparse_set.zig @@ -1,5 +1,4 @@ const std = @import("std"); -const warn = std.debug.warn; const utils = @import("utils.zig"); const registry = @import("registry.zig"); const ReverseSliceIterator = @import("utils.zig").ReverseSliceIterator; @@ -210,16 +209,16 @@ pub fn SparseSet(comptime SparseT: type) type { } fn printSet(set: *SparseSet(u32, u8)) void { - std.debug.warn("\nsparse -----\n", .{}); + std.debug.print("\nsparse -----\n", .{}); for (set.sparse.items) |sparse| { - std.debug.warn("{}\t", .{sparse}); + std.debug.print("{}\t", .{sparse}); } - std.debug.warn("\ndense -----\n", .{}); + std.debug.print("\ndense -----\n", .{}); for (set.dense.items) |dense| { - std.debug.warn("{}\t", .{dense}); + std.debug.print("{}\t", .{dense}); } - std.debug.warn("\n\n", .{}); + std.debug.print("\n\n", .{}); } test "add/remove/clear" { diff --git a/zig-ecs/src/process/scheduler.zig b/zig-ecs/src/process/scheduler.zig index 9d316e7..5e8f6b7 100644 --- a/zig-ecs/src/process/scheduler.zig +++ b/zig-ecs/src/process/scheduler.zig @@ -131,7 +131,7 @@ pub const Scheduler = struct { }; test "" { - std.debug.warn("\n", .{}); + std.debug.print("\n", .{}); const Tester = struct { process: Process, @@ -150,27 +150,27 @@ test "" { fn start(process: *Process) void { _ = process.getParent(@This()); - // std.debug.warn("start {}\n", .{self.fart}); + // std.debug.print("start {}\n", .{self.fart}); } fn aborted(process: *Process) void { _ = process.getParent(@This()); - // std.debug.warn("aborted {}\n", .{self.fart}); + // std.debug.print("aborted {}\n", .{self.fart}); } fn failed(process: *Process) void { _ = process.getParent(@This()); - // std.debug.warn("failed {}\n", .{self.fart}); + // std.debug.print("failed {}\n", .{self.fart}); } fn succeeded(process: *Process) void { _ = process.getParent(@This()); - // std.debug.warn("succeeded {}\n", .{self.fart}); + // std.debug.print("succeeded {}\n", .{self.fart}); } fn update(process: *Process) void { _ = process.getParent(@This()); - // std.debug.warn("update {}\n", .{self.fart}); + // std.debug.print("update {}\n", .{self.fart}); process.succeed(); } }; diff --git a/zig-ecs/tests/groups_test.zig b/zig-ecs/tests/groups_test.zig index a0e19d2..644d2be 100644 --- a/zig-ecs/tests/groups_test.zig +++ b/zig-ecs/tests/groups_test.zig @@ -1,5 +1,4 @@ const std = @import("std"); -const warn = std.debug.warn; const ecs = @import("ecs"); const Registry = @import("ecs").Registry; const BasicGroup = @import("ecs").BasicGroup; @@ -14,12 +13,12 @@ const Renderable = struct { x: f32 = 0 }; const Rotation = struct { x: f32 = 0 }; fn printStore(store: anytype, name: []const u8) void { - warn("--- {} ---\n", .{name}); + std.debug.print("--- {} ---\n", .{name}); for (store.set.dense.items) |e, i| { - warn("e[{}] s[{}]{}", .{ e, store.set.page(store.set.dense.items[i]), store.set.sparse.items[store.set.page(store.set.dense.items[i])] }); - warn(" ({d:.2}) ", .{store.instances.items[i]}); + std.debug.print("e[{}] s[{}]{}", .{ e, store.set.page(store.set.dense.items[i]), store.set.sparse.items[store.set.page(store.set.dense.items[i])] }); + std.debug.print(" ({d:.2}) ", .{store.instances.items[i]}); } - warn("\n", .{}); + std.debug.print("\n", .{}); } test "sort BasicGroup by Entity" { @@ -239,5 +238,5 @@ test "nested OwningGroups entity order" { // printStore(sprite_store, "Sprite"); // printStore(transform_store, "Transform"); - // warn("group2.current: {}\n", .{group2.group_data.current}); + // std.debug.print("group2.current: {}\n", .{group2.group_data.current}); }