Measure time to find icons in desktop entry test

This commit is contained in:
Ridan Vandenbergh 2025-06-21 12:55:16 +02:00
parent 9411ec941d
commit 06c0eec062
No known key found for this signature in database

View file

@ -414,6 +414,7 @@ mod test {
use crate::theme::{DirectoryType, ThemeIndex};
use std::error::Error;
use std::path::Path;
use std::time::{Duration, Instant};
#[test]
fn test_find_firefox() {
@ -456,6 +457,9 @@ mod test {
"signon-ui",
];
let mut time_taken = Duration::ZERO;
let mut n = 0;
for entry in
freedesktop_desktop_entry::Iter::new(freedesktop_desktop_entry::default_paths())
.entries(None::<&[&str]>)
@ -475,18 +479,25 @@ mod test {
continue;
}
let then = Instant::now();
// TODO: perhaps our system should expose a way to construct a "composed theme" filter,
// for cases where you want to search a multitude (or all) themes
let icon = icons
.find_icon(icon_name, 32, 1, "gnome")
.or_else(|| icons.find_icon(icon_name, 32, 1, "breeze"));
time_taken += Instant::now() - then;
n += 1;
assert!(
icon.is_some(),
"Icon {icon_name} from desktop entry {:?} missing!!",
entry.path
)
}
println!("avg {:?} per icon", time_taken / n);
}
#[test]