From 645d5163f3efe3c9f01a90684ea73eea2b4885d9 Mon Sep 17 00:00:00 2001 From: Antoine Gersant Date: Sun, 19 Jan 2020 14:28:04 -0800 Subject: [PATCH] More readable profile markers --- src/index/update.rs | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/index/update.rs b/src/index/update.rs index 1d08dd7..e97f90c 100644 --- a/src/index/update.rs +++ b/src/index/update.rs @@ -99,8 +99,15 @@ impl IndexUpdater { Ok(None) } - #[cfg_attr(feature = "profile-index", flame)] fn populate_directory(&mut self, parent: Option<&Path>, path: &Path) -> Result<()> { + + #[cfg(feature = "profile-index")] + let _guard = flame::start_guard(format!("dir: {}", + path.file_name().map(|s| { + s.to_string_lossy().into_owned() + }).unwrap_or("Unknown".to_owned()) + )); + // Find artwork let artwork = { #[cfg(feature = "profile-index")] @@ -140,8 +147,7 @@ impl IndexUpdater { // Insert content for file in fs::read_dir(path)? { - #[cfg(feature = "profile-index")] - let _guard = flame::start_guard("directory-entry"); + let file_path = match file { Ok(ref f) => f.path(), _ => { @@ -150,6 +156,13 @@ impl IndexUpdater { } }; + #[cfg(feature = "profile-index")] + let _guard = flame::start_guard(format!("file: {}", + file_path.as_path().file_name().map(|s| { + s.to_string_lossy().into_owned() + }).unwrap_or("Unknown".to_owned()) + )); + if file_path.is_dir() { sub_directories.push(file_path.to_path_buf()); continue; @@ -158,9 +171,6 @@ impl IndexUpdater { if let Some(file_path_string) = file_path.to_str() { if let Some(tags) = metadata::read(file_path.as_path()) { - #[cfg(feature = "profile-index")] - let _guard = flame::start_guard("process_song"); - if tags.year.is_some() { inconsistent_directory_year |= directory_year.is_some() && directory_year != tags.year;