#ebpf #android #uprobe #apps #frametime #analyzer #track

frame-analyzer

Track the frametime of Android apps, based on ebpf & uprobe

10 releases

0.3.3 Oct 26, 2024
0.3.2 Oct 25, 2024
0.2.7 Oct 3, 2024
0.2.6 Apr 23, 2024
0.1.31 Apr 21, 2024

#36 in #ebpf

Download history 34/week @ 2024-10-09 99/week @ 2024-10-16 562/week @ 2024-10-23 105/week @ 2024-10-30 113/week @ 2024-11-06 42/week @ 2024-11-13 28/week @ 2024-11-20 36/week @ 2024-11-27 41/week @ 2024-12-04 45/week @ 2024-12-11 19/week @ 2024-12-18 5/week @ 2024-12-25 24/week @ 2025-01-01 47/week @ 2025-01-08 54/week @ 2025-01-15 80/week @ 2025-01-22

205 downloads per month

GPL-3.0 license

29KB
339 lines

frame-analyzer-ebpf

Crates.io License Documentaiton

Track the frametime of Android apps, based on ebpf & uprobe

  • Based on the EBPF and UPROBE implementations, you may need higher privileges (e.g. root) to use this crate properly
  • This IS NOT a bin crate, it uses some tricks (see source) to get it to work like a normal lib crate, even though it includes an EBPF program
  • Only 64-bit devices & apps are supported!

Examples

Simple frametime analyzer, print pid & frametime on the screen

use std::sync::{
    atomic::{AtomicBool, Ordering},
    Arc,
};

use anyhow::Result;
use clap::Parser;
use frame_analyzer::Analyzer;

/// Simple frame analyzer, print frametime on the screen
#[derive(Parser, Debug)]
#[command(version, about)]
struct Args {
    /// The pid of the target application
    #[arg(short, long)]
    pid: i32,
}

fn main() -> Result<()> {
    let arg = Args::parse();
    let pid = arg.pid;

    let mut analyzer = Analyzer::new()?;
    analyzer.attach_app(pid)?;

    let running = Arc::new(AtomicBool::new(true));

    {
        let running = running.clone();
        ctrlc::set_handler(move || {
            running.store(false, Ordering::Release);
        })?;
    }

    while running.load(Ordering::Acquire) {
        if let Some((_, frametime)) = analyzer.recv() {
            println!("frametime: {frametime:?}");
        }
    }

    Ok(())
}

LICENSE

This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.

Dependencies

~7–15MB
~196K SLoC