framepace 0.1.0-alpha.0

Rolling frame-time statistics for game loops and real-time applications
Documentation
  • Coverage
  • 100%
    18 out of 18 items documented5 out of 6 items with examples
  • Size
  • Source code size: 55.72 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 648.68 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 2s Average build duration of successful builds.
  • all releases: 2s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • crates-lurey-io/framepace
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • matanlurey

framepace

Rolling frame-time statistics for game loops and real-time applications.

Test Docs Crates.io Version

framepace tracks per-frame wall-time durations in a fixed-size ring buffer and exposes mean, min, max, and percentile (p50, p95, p99) statistics over the window. No rendering. No rate-limiting. No loop control. Just measurement.

Usage

use framepace::FrameTimer;

let mut timer = FrameTimer::new();

// At the top of every tick:
timer.begin_frame();

// Query at any point:
if let Some(stats) = timer.stats() {
    println!("fps={:.1}  avg={:.2}ms  p95={:.2}ms", stats.fps, stats.avg_ms, stats.p95_ms);
}

Named phases let you break down where time is spent:

use framepace::FrameTimer;

let mut timer = FrameTimer::new();
timer.begin_frame();

{
    let _update = timer.phase("update");
    // ... update logic ...
}
{
    let _render = timer.phase("render");
    // ... render logic ...
}

if let Some(stats) = timer.phase_stats("render") {
    println!("render p95={:.2}ms", stats.p95_ms);
}

Plug in a custom time source for higher precision or WASM compatibility:

use framepace::{FrameTimer, TimeSource};

struct QuantaTime;

impl TimeSource for QuantaTime {
    fn now_us() -> u64 {
        // quanta::Instant::recent().as_u64() / 1_000
        0
    }
}

let mut timer: FrameTimer<64, QuantaTime> = FrameTimer::new();

Contributing

This project uses just to run commands the same way as CI:

  • just check — check formatting and lints
  • just test — run tests
  • just coverage — generate and preview code coverage
  • just doc — generate and preview docs

For a full list of commands, see the Justfile.

Releasing

  1. Update the version in Cargo.toml and CHANGELOG.md, then commit.
  2. Push a tag matching the version (e.g. v0.1.1).
  3. The publish workflow validates the tag, runs checks and tests, publishes to crates.io, and creates a GitHub Release with the changelog excerpt.