Skip to main content

Module timer

Module timer 

Source
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 std::time::Instant for relative durations. On wasm32 Instant is backed by performance.now() in current rustc, which is enough for demo profiling (Capacity’s 20 ms threshold) as well as native.

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 reset ticks to now. (b2GetMillisecondsAndReset)
get_ticks
Capture the current time. (b2GetTicks)