summaryrefslogtreecommitdiffstats
path: root/src/file_sum
diff options
context:
space:
mode:
authorCanop <cano.petrole@gmail.com>2020-12-01 17:34:25 +0100
committerCanop <cano.petrole@gmail.com>2020-12-01 17:34:25 +0100
commit9cc16fd465a4fc351c3990b6aaa2022a96da4dde (patch)
tree4f5fcea11935ade46cab004c7889a31dfe90d803 /src/file_sum
parent4f0632a74bfc11e3eebcc04ae6fede1a690ea606 (diff)
progressive display of file sums (size, counts, date)
More generally, all "pending tasks" (tasks that can be done after the first result) are done one per done, with screen redrawn at each step.
Diffstat (limited to 'src/file_sum')
-rw-r--r--src/file_sum/mod.rs4
-rw-r--r--src/file_sum/sum_computation.rs8
2 files changed, 6 insertions, 6 deletions
diff --git a/src/file_sum/mod.rs b/src/file_sum/mod.rs
index ffe2415..006f983 100644
--- a/src/file_sum/mod.rs
+++ b/src/file_sum/mod.rs
@@ -6,8 +6,8 @@ mod sum_computation;
use {
crate::task_sync::Dam,
+ fnv::FnvHashMap,
std::{
- collections::HashMap,
ops::AddAssign,
path::{Path, PathBuf},
sync::Mutex,
@@ -15,7 +15,7 @@ use {
};
lazy_static! {
- static ref SUM_CACHE_MUTEX: Mutex<HashMap<PathBuf, FileSum>> = Mutex::new(HashMap::new());
+ static ref SUM_CACHE_MUTEX: Mutex<FnvHashMap<PathBuf, FileSum>> = Mutex::new(FnvHashMap::default());
}
pub fn clear_cache() {
diff --git a/src/file_sum/sum_computation.rs b/src/file_sum/sum_computation.rs
index 6f65e87..942f54b 100644
--- a/src/file_sum/sum_computation.rs
+++ b/src/file_sum/sum_computation.rs
@@ -3,8 +3,8 @@ use {
crate::task_sync::Dam,
crossbeam::channel,
rayon::{ThreadPool, ThreadPoolBuilder},
+ fnv::FnvHashMap,
std::{
- collections::HashMap,
convert::TryInto,
fs,
path::{Path, PathBuf},
@@ -17,8 +17,8 @@ use {
#[cfg(unix)]
use {
+ fnv::FnvHashSet,
std::{
- collections::HashSet,
os::unix::fs::MetadataExt,
sync::Mutex,
},
@@ -41,7 +41,7 @@ const THREADS_COUNT: usize = 6;
/// varying depending on the OS:
/// On unix, the computation is done on blocks of 512 bytes
/// see https://doc.rust-lang.org/std/os/unix/fs/trait.MetadataExt.html#tymethod.blocks
-pub fn compute_dir_sum(path: &Path, cache: &mut HashMap<PathBuf, FileSum>, dam: &Dam) -> Option<FileSum> {
+pub fn compute_dir_sum(path: &Path, cache: &mut FnvHashMap<PathBuf, FileSum>, dam: &Dam) -> Option<FileSum> {
//debug!("compute size of dir {:?} --------------- ", path);
lazy_static! {
@@ -51,7 +51,7 @@ pub fn compute_dir_sum(path: &Path, cache: &mut HashMap<PathBuf, FileSum>, dam:
// to avoid counting twice a node, we store their id in a set
#[cfg(unix)]
- let nodes = Arc::new(Mutex::new(HashSet::<NodeId>::default()));
+ let nodes = Arc::new(Mutex::new(FnvHashSet::<NodeId>::default()));
// busy is the number of directories which are either being processed or queued
// We use this count to determine when threads can stop waiting for tasks