Something went wrong. Try again.
MIRROR: javascript for ๐'s, a tiny runtime with big ambitions ant.themackabu.dev
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829const std = @import("std");const builtin = @import("builtin");
pub var enabled: bool = false;
pub fn log(comptime fmt: []const u8, args: anytype) void { if (!enabled) return; var buf: [2048]u8 = undefined; const msg = std.fmt.bufPrint(&buf, "[pkg] " ++ fmt ++ "\n", args) catch return; if (comptime builtin.os.tag == .windows) { const handle = std.os.windows.GetStdHandle(std.os.windows.STD_ERROR_HANDLE) catch return; _ = std.os.windows.WriteFile(handle, msg, null) catch {}; } else _ = std.c.write(2, msg.ptr, msg.len);}
pub fn timer(comptime label: []const u8, start: u64) u64 { if (!enabled) return start; const now = std.time.nanoTimestamp(); const elapsed_ns: u64 = @intCast(now - @as(i128, start)); const elapsed_ms = elapsed_ns / 1_000_000; log("{s}: {d}ms", .{ label, elapsed_ms }); return @intCast(now);}