Time

Helpers for working with the monotonic clock.

These convert nanosecond durations and monotonic clock samples into seconds (F32) for animation and simulation math. The platform samples a Cycle once per host cycle and hands it over as input.time; everything else here is arithmetic on those numbers.

first_cycle : Cycle

Initial cycle sample used before any simulation time has elapsed.

to_seconds : U64 -> F32

Convert a nanosecond duration to seconds.

expect Time.to_seconds(500_000_000) == 0.5
delta_seconds : U64, U64 -> F32

Seconds elapsed between two clock samples. current must be at or after previous. Derive a delta from consecutive timestamp samples:

dt = Time.delta_seconds(model.last_tick, timestamp_nanos)
Cycle : { cycle_count : U64, simulation_nanos : U64, monotonic_nanos : U64, elapsed_seconds : F32 }

Timing samples attached to one host cycle.