mach: fundamental changes
- Core doesn't depend to `App` anymore - `setOptions` has replaced with some new functions (`setTitle`, `setSize`, etc) - and more
This commit is contained in:
parent
91a53807ab
commit
1d7cd4be80
26 changed files with 2306 additions and 1999 deletions
25
src/platform/wasm/Timer.zig
Normal file
25
src/platform/wasm/Timer.zig
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
const std = @import("std");
|
||||
const js = @import("js.zig");
|
||||
|
||||
pub const Timer = @This();
|
||||
|
||||
initial: f64 = undefined,
|
||||
|
||||
pub fn start() !Timer {
|
||||
return Timer{ .initial = js.machPerfNow() };
|
||||
}
|
||||
|
||||
pub fn read(timer: *Timer) u64 {
|
||||
return (js.machPerfNow() - timer.initial) * std.time.ns_per_ms;
|
||||
}
|
||||
|
||||
pub fn reset(timer: *Timer) void {
|
||||
timer.initial = js.machPerfNow();
|
||||
}
|
||||
|
||||
pub fn lap(timer: *Timer) u64 {
|
||||
const now = js.machPerfNow();
|
||||
const initial = timer.initial;
|
||||
timer.initial = now;
|
||||
return @floatToInt(u64, now - initial) * std.time.ns_per_ms;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue