mirror of
https://github.com/danbulant/icon
synced 2026-06-24 17:11:58 +00:00
Measure time to find icons in desktop entry test
This commit is contained in:
parent
9411ec941d
commit
06c0eec062
1 changed files with 11 additions and 0 deletions
11
src/theme.rs
11
src/theme.rs
|
|
@ -414,6 +414,7 @@ mod test {
|
||||||
use crate::theme::{DirectoryType, ThemeIndex};
|
use crate::theme::{DirectoryType, ThemeIndex};
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
use std::time::{Duration, Instant};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_find_firefox() {
|
fn test_find_firefox() {
|
||||||
|
|
@ -455,6 +456,9 @@ mod test {
|
||||||
"lstopo",
|
"lstopo",
|
||||||
"signon-ui",
|
"signon-ui",
|
||||||
];
|
];
|
||||||
|
|
||||||
|
let mut time_taken = Duration::ZERO;
|
||||||
|
let mut n = 0;
|
||||||
|
|
||||||
for entry in
|
for entry in
|
||||||
freedesktop_desktop_entry::Iter::new(freedesktop_desktop_entry::default_paths())
|
freedesktop_desktop_entry::Iter::new(freedesktop_desktop_entry::default_paths())
|
||||||
|
|
@ -475,11 +479,16 @@ mod test {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let then = Instant::now();
|
||||||
|
|
||||||
// TODO: perhaps our system should expose a way to construct a "composed theme" filter,
|
// 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
|
// for cases where you want to search a multitude (or all) themes
|
||||||
let icon = icons
|
let icon = icons
|
||||||
.find_icon(icon_name, 32, 1, "gnome")
|
.find_icon(icon_name, 32, 1, "gnome")
|
||||||
.or_else(|| icons.find_icon(icon_name, 32, 1, "breeze"));
|
.or_else(|| icons.find_icon(icon_name, 32, 1, "breeze"));
|
||||||
|
|
||||||
|
time_taken += Instant::now() - then;
|
||||||
|
n += 1;
|
||||||
|
|
||||||
assert!(
|
assert!(
|
||||||
icon.is_some(),
|
icon.is_some(),
|
||||||
|
|
@ -487,6 +496,8 @@ mod test {
|
||||||
entry.path
|
entry.path
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
println!("avg {:?} per icon", time_taken / n);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue