use gtk::prelude::*; use gtk::{gdk, 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()); } }