summaryrefslogtreecommitdiffstats
path: root/src/traverse.rs
diff options
context:
space:
mode:
authorSebastian Thiel <sebastian.thiel@icloud.com>2023-05-05 12:31:41 +0200
committerSebastian Thiel <sebastian.thiel@icloud.com>2023-05-05 12:34:47 +0200
commit13bfe4582f8cbf6f8f12e7ee8acaae710e8a87d2 (patch)
treeaa09f454cd7e2fa4d3c1551c0ad5c7c3c94090b9 /src/traverse.rs
parent565581fc11faf7512c27fe9095090f482a8d32f0 (diff)
feat: TUI now shows performance metrics while scanning and after.
This is in preparation for the `moonwalk` upgrade.
Diffstat (limited to 'src/traverse.rs')
-rw-r--r--src/traverse.rs13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/traverse.rs b/src/traverse.rs
index d33eed1..7296274 100644
--- a/src/traverse.rs
+++ b/src/traverse.rs
@@ -22,7 +22,7 @@ pub struct EntryData {
}
/// The result of the previous filesystem traversal
-#[derive(Default, Debug)]
+#[derive(Debug)]
pub struct Traversal {
/// A tree representing the entire filestem traversal
pub tree: Tree,
@@ -30,6 +30,10 @@ pub struct Traversal {
pub root_index: TreeIndex,
/// Amount of files or directories we have seen during the filesystem traversal
pub entries_traversed: u64,
+ /// The time at which the traversal started.
+ pub start: std::time::Instant,
+ /// The amount of time it took to finish the traversal. Set only once done.
+ pub elapsed: Option<std::time::Duration>,
/// Total amount of IO errors encountered when traversing the filesystem
pub io_errors: u64,
/// Total amount of bytes seen during the traversal
@@ -62,7 +66,11 @@ impl Traversal {
Traversal {
tree,
root_index,
- ..Default::default()
+ entries_traversed: 0,
+ start: std::time::Instant::now(),
+ elapsed: None,
+ io_errors: 0,
+ total_bytes: None,
}
};
@@ -201,6 +209,7 @@ impl Traversal {
set_size_or_panic(&mut t.tree, t.root_index, root_size);
t.total_bytes = Some(root_size);
+ t.elapsed = Some(t.start.elapsed());
Ok(Some(t))
}