From f7ca1dfd1dc9416d8206d7537d81c8838b86877f Mon Sep 17 00:00:00 2001 From: emostov <32168567+emostov@users.noreply.github.com> Date: Fri, 19 Nov 2021 15:14:54 +0100 Subject: [PATCH] Use saturating_duration_since, not elasped --- client/basic-authorship/src/basic_authorship.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/client/basic-authorship/src/basic_authorship.rs b/client/basic-authorship/src/basic_authorship.rs index 19633b56a599a..79e38fe0f5abd 100644 --- a/client/basic-authorship/src/basic_authorship.rs +++ b/client/basic-authorship/src/basic_authorship.rs @@ -346,16 +346,19 @@ where block_size_limit: Option, ) -> Result, PR::Proof>, sp_blockchain::Error> { - let block_proposal_timer = time::Instant::now(); + let propose_with_start = time::Instant::now(); let mut block_builder = self.client.new_block_at(&self.parent_id, inherent_digests, PR::ENABLED)?; - let create_inherents_timer = time::Instant::now(); + let create_inherents_start = time::Instant::now(); let inherents = block_builder.create_inherents(inherent_data)?; + let create_inherents_end = time::Instant::now(); + self.metrics.report(|metrics| { metrics .create_inherents_time - .observe(create_inherents_timer.elapsed().as_secs_f64()); + .observe(create_inherents_start + .saturating_duration_since(create_inherents_end).as_secs_f64()); }); for inherent in inherents { @@ -539,10 +542,11 @@ where let proof = PR::into_proof(proof).map_err(|e| sp_blockchain::Error::Application(Box::new(e)))?; + let propose_with_end = time::Instant::now(); self.metrics.report(|metrics| { metrics .create_block_proposal_time - .observe(block_proposal_timer.elapsed().as_secs_f64()); + .observe(propose_with_start.saturating_duration_since(propose_with_end).as_secs_f64()); }); Ok(Proposal { block, proof, storage_changes })