Files
gtk-ahfail/crates/ahfail-gtklock/tests/benchmarks.rs
Asger Geel Weirsøe 1f927bdbb2
Some checks failed
Test / test (push) Failing after 6m22s
fix: run cargo test under xvfb-run; clean up unused imports and mut warning
ahfail_tests.rs calls on_activation which initialises GTK — needs a virtual
display in CI just like the Meson test step.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-06 13:04:56 +02:00

57 lines
1.4 KiB
Rust

use gtk::gdk_pixbuf;
use gstreamer as gst;
use gstreamer_player as gst_player;
use std::time::Instant;
#[cfg(test)]
mod benchmarks {
use super::*;
use std::sync::Once;
static INIT: Once = Once::new();
fn init() {
INIT.call_once(|| {
gtk::init().unwrap();
gst::init().unwrap();
});
}
#[test]
fn bench_pixbuf_loading() {
init();
let start = Instant::now();
// Create a 1x1 pixbuf to simulate loading
let _pixbuf = gdk_pixbuf::Pixbuf::new(gdk_pixbuf::Colorspace::Rgb, false, 8, 220, 220).unwrap();
println!("Pixbuf creation: {:?}", start.elapsed());
}
#[test]
fn bench_animation_creation() {
init();
let start = Instant::now();
let _anim = gdk_pixbuf::PixbufSimpleAnim::new(220, 220, 12.0);
println!("Animation creation: {:?}", start.elapsed());
}
#[test]
fn bench_player_creation() {
init();
let start = Instant::now();
let _player = gst_player::Player::new(None, None);
println!("GstPlayer creation: {:?}", start.elapsed());
}
#[test]
fn bench_coord_calculation() {
use rand::Rng;
let start = Instant::now();
let mut rng = rand::thread_rng();
for _ in 0..1000 {
let _x = rng.gen_range(0..1920);
let _y = rng.gen_range(0..1080);
}
println!("1000 RNG calculations: {:?}", start.elapsed());
}
}