ray-project--ray
952 B
952 B
paths
| paths | |
|---|---|
|
- Excluding the Clock implementation and benchmarks, read the current time only through an injected
ray::ClockInterface(src/ray/util/clock.h) so time can be faked and unit tested deterministically. Do not callabsl::Now(),std::chrono::{system,steady,high_resolution}_clock::now(), or other similar functions. - Inject
ClockInterface &clock_via the constructor. Pass aClockfrom the production entrypoint (e.g.raylet/main.cc) and aFakeClockin tests. Declare the concrete clock member before any object that holds aClockInterface &so it is constructed first and outlives the holder. - Use
clock_.Now()/clock_.NowUnixMillis()for wall-clock timestamps and deadlines, andclock_.SteadyNow()for elapsed/duration measurements - In unit tests use
FakeClock::AdvanceTime/SetTimeinstead ofsleepor wall-clock time. Ensure that the tests are written to be fast and deterministic.