test: improve tests and fmt all
This commit is contained in:
parent
73702f6049
commit
b7c9865412
2 changed files with 47 additions and 29 deletions
|
|
@ -3,48 +3,42 @@ use freedesktop_icons::lookup;
|
|||
use gtk4::{IconLookupFlags, IconTheme, TextDirection};
|
||||
|
||||
pub fn simple_bench(c: &mut Criterion) {
|
||||
c.bench_function("firefox lookup", |b| b.iter(||
|
||||
lookup("firefox")
|
||||
.with_theme("Papirus")
|
||||
.with_cache()
|
||||
.find()
|
||||
));
|
||||
c.bench_function("firefox lookup", |b| {
|
||||
b.iter(|| lookup("firefox").with_theme("Papirus").with_cache().find())
|
||||
});
|
||||
}
|
||||
|
||||
pub fn bench_lookups(c: &mut Criterion) {
|
||||
let mut group = c.benchmark_group("ComparisonsLookups");
|
||||
|
||||
let args = [
|
||||
"user-home", // (Best case) An icon that can be found in the current theme
|
||||
"video-single-display-symbolic", // An icon that can be found in the parent theme
|
||||
"firefox", // An icon that can be found in the hicolor default theme
|
||||
"archlinux-logo", // An icon that resides in /usr/share/pixmap
|
||||
"not-found", // (Worst case) An icon that does not exist
|
||||
"user-home", // (Best case) An icon that can be found in the current theme
|
||||
"video-single-display-symbolic", // An icon that can be found in the parent theme
|
||||
"firefox", // An icon that can be found in the hicolor default theme
|
||||
"archlinux-logo", // An icon that resides in /usr/share/pixmap
|
||||
"not-found", // (Worst case) An icon that does not exist
|
||||
];
|
||||
|
||||
for arg in args {
|
||||
group.bench_with_input(BenchmarkId::new("freedesktop-icons lookup", arg), arg, |b, arg| {
|
||||
b.iter(|| lookup(arg)
|
||||
.with_theme("Arc")
|
||||
.find());
|
||||
});
|
||||
group.bench_with_input(
|
||||
BenchmarkId::new("freedesktop-icons lookup", arg),
|
||||
arg,
|
||||
|b, arg| {
|
||||
b.iter(|| lookup(arg).with_theme("Arc").find());
|
||||
},
|
||||
);
|
||||
|
||||
group.bench_with_input(BenchmarkId::new("lookup with cache", arg), arg, |b, arg| {
|
||||
b.iter(|| lookup(arg)
|
||||
.with_theme("Arc")
|
||||
.with_cache()
|
||||
.find());
|
||||
b.iter(|| lookup(arg).with_theme("Arc").with_cache().find());
|
||||
});
|
||||
|
||||
group.bench_with_input(BenchmarkId::new("lookup linicon", arg), arg, |b, arg| {
|
||||
b.iter(|| linicon::lookup_icon(arg)
|
||||
.from_theme("Arc")
|
||||
.next());
|
||||
b.iter(|| linicon::lookup_icon(arg).from_theme("Arc").next());
|
||||
});
|
||||
|
||||
group.bench_with_input(BenchmarkId::new("lookup gtk", arg), arg, |b, arg| {
|
||||
gtk4::init().unwrap();
|
||||
let theme = IconTheme::new();
|
||||
gtk4::init().unwrap();
|
||||
let theme = IconTheme::new();
|
||||
b.iter(|| {
|
||||
theme.lookup_icon(
|
||||
arg,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue