# Time ## The time base runs at 49.875 MHz `mftb` counts at the CPU clock / 64 = **49.875 MHz**. `KeQueryPerformanceFrequency` reports 50 MHz, which would put everything 0.25% off. xsdk measured this against the 60 Hz display (16,625 time base ticks at "50 MHz" per frame = 16,667 µs at 49.875 MHz). `xex_timebase_freq()` returns 49,875,000. Xenia runs its time base at 50 MHz, so times there read 0.25% long. ## Wall clock, clock(), sleeping - `gettimeofday` and `time()` come from `KeQuerySystemTime`. - `clock()` and `times()` count the time base. - `xex_sleep_ms` and `usleep` use `KeDelayExecutionThread`. The kernel's sleep can end a little early, so spin for the last millisecond when timing frames. ## Frame pacing - **60 fps:** let the display pace you. `xex_video_begin()` waits until the previous flip is on screen, so draw-then-present runs at the refresh rate. An FPS counter over a "second" shows 60 or 61, depending on the window edges. - **30 fps and others:** sleep to a time base target. Sleep in short slices if audio has to be refilled meanwhile; see [Audio](Audio.md). - **Under the Guide**, frames don't latch at vertical blank; see [The Guide](The-Guide.md).