From 88b17bcec12dcd040ac6d52a92b6a22a14332a8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Mikrut?= Date: Sun, 5 Jan 2025 23:31:46 +0100 Subject: [PATCH] Test --- .github/workflows/linux_cli_eyra.yml | 2 +- .github/workflows/minimial_version.yml | 2 +- .gitignore | 4 + Cargo.toml | 1 + czkawka_cli/Cargo.toml | 2 +- czkawka_cli/LICENSE | 2 +- czkawka_cli/README.md | 2 +- czkawka_core/Cargo.toml | 2 +- czkawka_core/LICENSE | 2 +- czkawka_gui/Cargo.toml | 2 +- czkawka_gui/LICENSE | 2 +- czkawka_gui/README.md | 2 +- czkawka_gui/src/gui_structs/gui_about.rs | 2 +- czkawka_gui/ui/about_dialog.ui | 2 +- czkawka_gui/ui/czkawka.cmb | 2 +- instructions/Compilation.md | 2 +- krokiet/Cargo.toml | 2 +- krokiet/LICENSE_MIT_CODE | 2 +- krokiet/ui/about.slint | 2 +- misc/test_image_perf/Cargo.toml | 15 ++++ misc/test_image_perf/src/main.rs | 103 +++++++++++++++++++++++ snap/snapcraft.yaml | 2 +- 22 files changed, 141 insertions(+), 18 deletions(-) create mode 100644 misc/test_image_perf/Cargo.toml create mode 100644 misc/test_image_perf/src/main.rs diff --git a/.github/workflows/linux_cli_eyra.yml b/.github/workflows/linux_cli_eyra.yml index cf5fb1521..2a0f3fe07 100644 --- a/.github/workflows/linux_cli_eyra.yml +++ b/.github/workflows/linux_cli_eyra.yml @@ -19,7 +19,7 @@ jobs: # New versions of nightly rust may call new unimplemented in eyra functions, so use const version - name: Setup rust version - run: rustup default nightly-2024-09-25 + run: rustup default nightly-2025-01-01 - name: Add eyra run: | diff --git a/.github/workflows/minimial_version.yml b/.github/workflows/minimial_version.yml index 8727244e1..e947cce6e 100644 --- a/.github/workflows/minimial_version.yml +++ b/.github/workflows/minimial_version.yml @@ -18,7 +18,7 @@ jobs: run: sudo apt update || true; sudo apt install libgtk-4-dev libheif-dev libraw-dev ffmpeg -y - name: Setup rust version - run: rustup default 1.81.0 + run: rustup default 1.82.0 - name: Build run: | diff --git a/.gitignore b/.gitignore index 257863a60..e89147431 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,7 @@ krokiet/target perf.data perf.data.old krokiet/ui/test.slint + +misc/*/*.lock +misc/*/target/ +misc/*/.idea diff --git a/Cargo.toml b/Cargo.toml index 2d5dd43ea..97d1d51d1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,6 +7,7 @@ members = [ ] exclude = [ "misc/test_read_perf", + "misc/test_image_perf", "ci_tester", ] resolver = "2" diff --git a/czkawka_cli/Cargo.toml b/czkawka_cli/Cargo.toml index f62f4a650..775960e3f 100644 --- a/czkawka_cli/Cargo.toml +++ b/czkawka_cli/Cargo.toml @@ -3,7 +3,7 @@ name = "czkawka_cli" version = "8.0.0" authors = ["Rafał Mikrut "] edition = "2021" -rust-version = "1.81.0" +rust-version = "1.82.0" description = "CLI frontend of Czkawka" license = "MIT" homepage = "https://github.com/qarmin/czkawka" diff --git a/czkawka_cli/LICENSE b/czkawka_cli/LICENSE index 298d0d42f..4d9894a93 100644 --- a/czkawka_cli/LICENSE +++ b/czkawka_cli/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2020-2024 Rafał Mikrut +Copyright (c) 2020-2025 Rafał Mikrut Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/czkawka_cli/README.md b/czkawka_cli/README.md index 3c29dd675..1548643b3 100644 --- a/czkawka_cli/README.md +++ b/czkawka_cli/README.md @@ -39,7 +39,7 @@ on linux to build fully static binary with eyra you need to use (this is only fo above if you don't know what you are doing) ```shell -rustup default nightly-2024-09-25 # or any newer nightly that works fine with eyra +rustup default nightly-2025-01-01 # or any newer nightly that works fine with eyra cd czkawka_cli cargo add eyra --rename=std echo 'fn main() { println!("cargo:rustc-link-arg=-nostartfiles"); }' > build.rs diff --git a/czkawka_core/Cargo.toml b/czkawka_core/Cargo.toml index 105f92c3d..3652babd3 100644 --- a/czkawka_core/Cargo.toml +++ b/czkawka_core/Cargo.toml @@ -3,7 +3,7 @@ name = "czkawka_core" version = "8.0.0" authors = ["Rafał Mikrut "] edition = "2021" -rust-version = "1.81.0" +rust-version = "1.82.0" description = "Core of Czkawka app" license = "MIT" homepage = "https://github.com/qarmin/czkawka" diff --git a/czkawka_core/LICENSE b/czkawka_core/LICENSE index 298d0d42f..4d9894a93 100644 --- a/czkawka_core/LICENSE +++ b/czkawka_core/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2020-2024 Rafał Mikrut +Copyright (c) 2020-2025 Rafał Mikrut Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/czkawka_gui/Cargo.toml b/czkawka_gui/Cargo.toml index 40c02f037..e965c0dfb 100644 --- a/czkawka_gui/Cargo.toml +++ b/czkawka_gui/Cargo.toml @@ -3,7 +3,7 @@ name = "czkawka_gui" version = "8.0.0" authors = ["Rafał Mikrut "] edition = "2021" -rust-version = "1.81.0" +rust-version = "1.82.0" description = "GTK frontend of Czkawka" license = "MIT" homepage = "https://github.com/qarmin/czkawka" diff --git a/czkawka_gui/LICENSE b/czkawka_gui/LICENSE index c3996b354..b95e604c1 100644 --- a/czkawka_gui/LICENSE +++ b/czkawka_gui/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2020-2024 Rafał Mikrut +Copyright (c) 2020-2025 Rafał Mikrut Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/czkawka_gui/README.md b/czkawka_gui/README.md index ade6c3bfa..df07db513 100644 --- a/czkawka_gui/README.md +++ b/czkawka_gui/README.md @@ -71,7 +71,7 @@ lot build and runtime dependencies. | Program | Minimal version | |:-------:|:---------------:| -| Rust | 1.81.0 | +| Rust | 1.82.0 | | GTK | 4.6 | ### Linux (Ubuntu, but on other OS should work similar) diff --git a/czkawka_gui/src/gui_structs/gui_about.rs b/czkawka_gui/src/gui_structs/gui_about.rs index dcae0016a..3e38cb3d3 100644 --- a/czkawka_gui/src/gui_structs/gui_about.rs +++ b/czkawka_gui/src/gui_structs/gui_about.rs @@ -125,7 +125,7 @@ impl GuiAbout { } pub fn update_language(&self) { - let mut comment_text: String = "2020 - 2024 Rafał Mikrut(qarmin)\n\n".to_string(); + let mut comment_text: String = "2020 - 2025 Rafał Mikrut(qarmin)\n\n".to_string(); comment_text += &flg!("about_window_motto"); self.about_dialog.set_comments(Some(&comment_text)); diff --git a/czkawka_gui/ui/about_dialog.ui b/czkawka_gui/ui/about_dialog.ui index 2e367c814..2bab60ff7 100644 --- a/czkawka_gui/ui/about_dialog.ui +++ b/czkawka_gui/ui/about_dialog.ui @@ -4,7 +4,7 @@ - 2020 - 2024 + 2020 - 2025 Rafał Mikrut (qarmin) and contributors This program is free to use and will always be. mit-x11 diff --git a/czkawka_gui/ui/czkawka.cmb b/czkawka_gui/ui/czkawka.cmb index a5909357e..ddd152c24 100755 --- a/czkawka_gui/ui/czkawka.cmb +++ b/czkawka_gui/ui/czkawka.cmb @@ -344,7 +344,7 @@ (10,7,"GtkButton","buttons_popover_sort_selection",2,None,None,None,4,None,None) - (3,1,"GtkAboutDialog","comments","2020 - 2024\nRafał Mikrut (qarmin) and contributors\nThis program is free to use and will always be.",1,None,None,None,None,None,None,None,None), + (3,1,"GtkAboutDialog","comments","2020 - 2025\nRafał Mikrut (qarmin) and contributors\nThis program is free to use and will always be.",1,None,None,None,None,None,None,None,None), (3,1,"GtkAboutDialog","license-type","mit-x11",None,None,None,None,None,None,None,None,None), (3,1,"GtkAboutDialog","logo-icon-name","help-about-symbolic",None,None,None,None,None,None,None,None,None), (3,1,"GtkAboutDialog","program-name","Czkawka",None,None,None,None,None,None,None,None,None), diff --git a/instructions/Compilation.md b/instructions/Compilation.md index 1c0e820c1..2246f6e59 100644 --- a/instructions/Compilation.md +++ b/instructions/Compilation.md @@ -20,7 +20,7 @@ New versions of GTK fixes some bugs, so e.g. middle button selection will work o | Program | Min | What for | |---------|--------|--------------------------------------------------------------------------------------| -| Rust | 1.81.0 | The minimum version of rust does not depend on anything, so it can change frequently | +| Rust | 1.82.0 | The minimum version of rust does not depend on anything, so it can change frequently | | GTK | 4.6 | Only for the `GTK` backend | #### Debian / Ubuntu diff --git a/krokiet/Cargo.toml b/krokiet/Cargo.toml index 57545eddb..16db18865 100644 --- a/krokiet/Cargo.toml +++ b/krokiet/Cargo.toml @@ -3,7 +3,7 @@ name = "krokiet" version = "8.0.0" authors = ["Rafał Mikrut "] edition = "2021" -rust-version = "1.81.0" +rust-version = "1.82.0" description = "Slint frontend of Czkawka Core" license = "GPL-3.0-only" homepage = "https://github.com/qarmin/czkawka" diff --git a/krokiet/LICENSE_MIT_CODE b/krokiet/LICENSE_MIT_CODE index 298d0d42f..4d9894a93 100644 --- a/krokiet/LICENSE_MIT_CODE +++ b/krokiet/LICENSE_MIT_CODE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2020-2024 Rafał Mikrut +Copyright (c) 2020-2025 Rafał Mikrut Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/krokiet/ui/about.slint b/krokiet/ui/about.slint index 262f96d80..f07f7c620 100644 --- a/krokiet/ui/about.slint +++ b/krokiet/ui/about.slint @@ -21,7 +21,7 @@ export component About inherits VerticalLayout { spacing: 10px; padding-bottom: 10px; Text { - text: "2020 - 2024 Rafał Mikrut(qarmin)"; + text: "2020 - 2025 Rafał Mikrut(qarmin)"; horizontal-alignment: center; font-size: 15px; } diff --git a/misc/test_image_perf/Cargo.toml b/misc/test_image_perf/Cargo.toml new file mode 100644 index 000000000..586b8e21d --- /dev/null +++ b/misc/test_image_perf/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "test_image_perf" +version = "0.1.0" +edition = "2021" + +[dependencies] +walkdir = "2.5.0" +humansize = "2.1.3" +rayon = "1.10.0" +strum = { version = "0.26.3", features = ["strum_macros", "derive"] } +image_hasher = "3.0.0" +image = "0.25.5" + +[features] +fast_image_resize = ["image_hasher/fast_resize_unstable"] \ No newline at end of file diff --git a/misc/test_image_perf/src/main.rs b/misc/test_image_perf/src/main.rs new file mode 100644 index 000000000..8383f4a8e --- /dev/null +++ b/misc/test_image_perf/src/main.rs @@ -0,0 +1,103 @@ +use image_hasher::{FilterType, HashAlg, HasherConfig}; +use rayon::prelude::*; +use std::env; +use std::process::Command; +use walkdir::WalkDir; + +const DIR_TO_CHECK: &str = "/media/rafal/Kotyk/Rafał/Camera"; + +const ITERATIONS: usize = 5; +const HASH_ALG: HashAlg = HashAlg::Gradient; +const FILTER_TYPE: FilterType = FilterType::Lanczos3; +const HASH_SIZE: u32 = 64; + +#[cfg(not(feature = "fast_image_resize"))] +const MODE: &str = "NORMAL"; +#[cfg(feature = "fast_image_resize")] +const MODE: &str = "FAST_RESIZE"; + +fn main() { + if !is_running_as_sudo() { + println!("Please run this program as root"); + return; + } + + clean_disk_cache(); + + let collected_image_files = WalkDir::new(DIR_TO_CHECK) + .into_iter() + .flatten() + .map(|e| e.path().to_path_buf()) + .filter_map(|e| { + let ext = e.extension().unwrap_or_default().to_str().unwrap_or_default().to_lowercase(); + if ["jpg", "png", "jpeg", "webp"].contains(&ext.as_str()) { + return Some(e.to_str().unwrap_or_default().to_string()); + } + None + }) + .collect::>(); + + println!("Collected {} image files", collected_image_files.len()); + + let mut times = vec![]; + + for i in 0..ITERATIONS { + println!("Iteration {}", i + 1); + clean_disk_cache(); + + let start = std::time::Instant::now(); + + collected_image_files.par_iter().for_each(|e| { + let _ = hash_image(e); + }); + + let elapsed = start.elapsed(); + println!("Iteration {} took {} ms", i + 1, elapsed.as_millis()); + times.push(elapsed.as_micros()); + } + + let total_time = times.iter().sum::(); + let all_iterations_time = total_time as f64 / 1000.0; + + let iters_without_extremes = times.len().checked_sub(2).unwrap_or_default(); + let total_time_without_extremes = total_time - times.iter().min().copied().unwrap_or_default() - times.iter().max().copied().unwrap_or_default(); + let all_iterations_time_without_extremes = total_time_without_extremes as f64 / 1000.0; + println!( + "Mode {}, {} iterations, total time: {} ms, per iteration time {} ms, total time without extremes: {} ms, per iteration time without extremes {} ms", + MODE, + ITERATIONS, + all_iterations_time, + all_iterations_time / ITERATIONS as f64, + all_iterations_time_without_extremes, + all_iterations_time_without_extremes / iters_without_extremes as f64 + ); +} + +fn hash_image(hash_image: &str) -> Result<(), String> { + let img = image::open(hash_image).map_err(|e| format!("Cannot open image file \"{hash_image}\": {e}"))?; + + let hasher_config = HasherConfig::new().hash_size(HASH_SIZE, HASH_SIZE).hash_alg(HASH_ALG).resize_filter(FILTER_TYPE); + let hasher = hasher_config.to_hasher(); + let _hash = hasher.hash_image(&img); + + Ok(()) +} + +fn clean_disk_cache() { + let _sync = Command::new("sync").output().expect("Failed to execute sync"); + let _drop_caches = Command::new("sh") + .arg("-c") + .arg("echo 3 > /proc/sys/vm/drop_caches") + .output() + .expect("Failed to execute drop_caches"); +} + +fn is_running_as_sudo() -> bool { + match env::var("EUID") { + Ok(euid) => euid == "0", + Err(_) => match env::var("USER") { + Ok(user) => user == "root", + Err(_) => false, + }, + } +} diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 89c496c07..49c7f9eb8 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -17,7 +17,7 @@ donation: https://github.com/sponsors/qarmin parts: rust-deps: plugin: nil - override-pull: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain 1.81.0 + override-pull: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain 1.82.0 czkawka: plugin: rust after: [ rust-deps ]