Expand description
Port of the timing helpers from box2d-cpp-reference/src/timer.c
(b2GetTicks, b2GetMilliseconds, b2GetMillisecondsAndReset).
Mutex / semaphore / thread wrappers from that file are not ported — Rust’s standard library covers them. Only the profiling clock remains.
Uses an Instant for relative durations. On native targets this is
std::time::Instant. On wasm32-unknown-unknown, std::time::Instant::now()
panics (“time not implemented on this platform”), so we use the web-time
crate there instead — its Instant is backed by performance.now(). That
provides real wall-clock values needed for demo profiling (Capacity’s 20 ms
threshold) without trapping every world step.
SPDX-FileCopyrightText: 2023 Erin Catto SPDX-License-Identifier: MIT
Structs§
- Ticks
- Opaque tick capture. (return value of
b2GetTicks)
Functions§
- get_
milliseconds - Milliseconds elapsed since
ticks. (b2GetMilliseconds) - get_
milliseconds_ and_ reset - Milliseconds elapsed since
ticks, then resetticksto now. (b2GetMillisecondsAndReset) - get_
ticks - Capture the current time. (
b2GetTicks)