gpu-histop 0.1.0

High-resolution GPU history monitor for NVIDIA, AMDGPU, and Apple Silicon
Documentation
use anyhow::{Context, Result};
use clap::Parser;
use gpu_histop::backend::create_backend;
use gpu_histop::config::Args;
use gpu_histop::sampler::spawn_sampler;
use gpu_histop::ui::{App, TuiConfig};

fn main() -> Result<()> {
    let args = Args::parse();
    let backend =
        create_backend(args.backend).with_context(|| "failed to initialize GPU metrics backend")?;

    let backend_label = backend.label().to_owned();
    let devices = backend.devices().to_vec();
    let (rx, sampler) = spawn_sampler(backend, args.sample_interval());

    let app = App::new(
        devices,
        backend_label,
        rx,
        TuiConfig {
            sample_interval: args.sample_interval(),
            frame_interval: args.frame_interval(),
            history_retention: args.history_retention(),
            initial_window: args.window(),
        },
    );

    let mut terminal = ratatui::init();
    let result = gpu_histop::ui::run(&mut terminal, app);
    ratatui::restore();
    sampler.stop();

    result
}