Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
  • Loading branch information
qarmin committed Jan 5, 2025
1 parent 336763e commit 88b17bc
Show file tree
Hide file tree
Showing 22 changed files with 141 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/linux_cli_eyra.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/minimial_version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@ krokiet/target
perf.data
perf.data.old
krokiet/ui/test.slint

misc/*/*.lock
misc/*/target/
misc/*/.idea
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ members = [
]
exclude = [
"misc/test_read_perf",
"misc/test_image_perf",
"ci_tester",
]
resolver = "2"
Expand Down
2 changes: 1 addition & 1 deletion czkawka_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "czkawka_cli"
version = "8.0.0"
authors = ["Rafał Mikrut <[email protected]>"]
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"
Expand Down
2 changes: 1 addition & 1 deletion czkawka_cli/LICENSE
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion czkawka_cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion czkawka_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "czkawka_core"
version = "8.0.0"
authors = ["Rafał Mikrut <[email protected]>"]
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"
Expand Down
2 changes: 1 addition & 1 deletion czkawka_core/LICENSE
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion czkawka_gui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "czkawka_gui"
version = "8.0.0"
authors = ["Rafał Mikrut <[email protected]>"]
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"
Expand Down
2 changes: 1 addition & 1 deletion czkawka_gui/LICENSE
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion czkawka_gui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion czkawka_gui/src/gui_structs/gui_about.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
2 changes: 1 addition & 1 deletion czkawka_gui/ui/about_dialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<!-- interface-name about_dialog.ui -->
<requires lib="gtk" version="4.6"/>
<object class="GtkAboutDialog" id="about_dialog">
<property name="comments" translatable="yes">2020 - 2024
<property name="comments" translatable="yes">2020 - 2025
Rafał Mikrut (qarmin) and contributors
This program is free to use and will always be.</property>
<property name="license-type">mit-x11</property>
Expand Down
2 changes: 1 addition & 1 deletion czkawka_gui/ui/czkawka.cmb
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@
(10,7,"GtkButton","buttons_popover_sort_selection",2,None,None,None,4,None,None)
</object>
<object_property>
(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),
Expand Down
2 changes: 1 addition & 1 deletion instructions/Compilation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion krokiet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "krokiet"
version = "8.0.0"
authors = ["Rafał Mikrut <[email protected]>"]
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"
Expand Down
2 changes: 1 addition & 1 deletion krokiet/LICENSE_MIT_CODE
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion krokiet/ui/about.slint
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
15 changes: 15 additions & 0 deletions misc/test_image_perf/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"]
103 changes: 103 additions & 0 deletions misc/test_image_perf/src/main.rs
Original file line number Diff line number Diff line change
@@ -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::<Vec<String>>();

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::<u128>();
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,
},
}
}
2 changes: 1 addition & 1 deletion snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ]
Expand Down

0 comments on commit 88b17bc

Please sign in to comment.