More readable profile markers

This commit is contained in:
Antoine Gersant 2020-01-19 14:28:04 -08:00
parent 028633d0e6
commit 645d5163f3

View file

@ -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;