rat-fps 0.1.1

Widget to show FPS in ratatui
Documentation
  • Coverage
  • 75%
    3 out of 4 items documented0 out of 3 items with examples
  • Size
  • Source code size: 23.2 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 410.5 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 30s Average build duration of successful builds.
  • all releases: 30s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Borwe

RAT-FPS

Description:

A Widget for use with Ratatui to display FPS

Example Usage:

use std::{error::Error, time::Duration};

use rat_fps::FPS;
use ratatui::crossterm::{self, event::{Event, KeyCode, KeyEvent}};

fn main() -> Result<(), Box<dyn Error>> {
    let mut term = ratatui::init();
    let mut keep_running = true;
    let mut fps = FPS::new()?;

    while keep_running {
        term.draw(|f|{
            //render the fps
            f.render_widget(&mut fps, f.area());
        })?;

        //wait roughly to enable rpughly atleast 60fps if possible, 
        // note what you do after the poll might reduce fps if not fast enough,
        // in such cases it is adviced to have a higher wait for fps,
        //roughly 30+ above expected
        if crossterm::event::poll(Duration::from_millis(fps.wait_for_fps(60)?))? {
            if let Event::Key(KeyEvent{ 
                code: KeyCode::Char('q'), ..}) = crossterm::event::read()? {
                keep_running = false;
            }
        }
    }

    ratatui::restore();
    Ok(())
}