From dd13fde5ea8bd61b6b5c7f024df6733301864456 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sat, 2 Apr 2022 15:54:02 +0300 Subject: feat: collect and log some time metrics Log the complete run-time of the program, and the time spent downloading the previous generation, and uploading the new generation. Sponsored-by: author --- src/backup_run.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/backup_run.rs') diff --git a/src/backup_run.rs b/src/backup_run.rs index 21140ba..29e82fc 100644 --- a/src/backup_run.rs +++ b/src/backup_run.rs @@ -15,6 +15,7 @@ use crate::fsiter::{AnnotatedFsEntry, FsIterError, FsIterator}; use crate::generation::{ GenId, LocalGeneration, LocalGenerationError, NascentError, NascentGeneration, }; +use crate::performance::{Clock, Performance}; use crate::policy::BackupPolicy; use crate::schema::SchemaVersion; @@ -129,6 +130,7 @@ impl<'a> BackupRun<'a> { &mut self, genid: Option<&GenId>, oldname: &Path, + perf: &mut Performance, ) -> Result { match genid { None => { @@ -140,7 +142,9 @@ impl<'a> BackupRun<'a> { Ok(LocalGeneration::open(oldname)?) } Some(genid) => { + perf.start(Clock::GenerationDownload); let old = self.fetch_previous_generation(genid, oldname).await?; + perf.stop(Clock::GenerationDownload); let progress = BackupProgress::incremental(); progress.files_in_previous_generation(old.file_count()? as u64); @@ -176,6 +180,7 @@ impl<'a> BackupRun<'a> { old: &LocalGeneration, newpath: &Path, schema: SchemaVersion, + perf: &mut Performance, ) -> Result { let mut warnings: Vec = vec![]; let mut new_cachedir_tags = vec![]; @@ -204,7 +209,9 @@ impl<'a> BackupRun<'a> { count }; self.finish(); + perf.start(Clock::GenerationUpload); let gen_id = self.upload_nascent_generation(newpath).await?; + perf.stop(Clock::GenerationUpload); let gen_id = GenId::from_chunk_id(gen_id); Ok(RootsBackupOutcome { files_count, -- cgit v1.2.1