Use std.debug.print instead of std.debug.warn

master
Austin Rude 3 years ago
parent a95c85f5c7
commit 0fe6d1646f

@ -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()});
// }
}

@ -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 });
}
}

@ -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 {

@ -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;

@ -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" {

@ -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();
}
};

@ -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});
}

Loading…
Cancel
Save