[contracts] Add upfront weight of merkle trie proofs for storage reading functions (#13236)

* Add upfront weight of merkle trie proofs for storage reading functions

* drive-by fixes
This commit is contained in:
Sasha Gryaznov
2023-01-25 20:12:29 +02:00
committed by GitHub
parent 3b03862caf
commit 2a38f4122a
3 changed files with 16 additions and 13 deletions
@@ -124,21 +124,24 @@ fn format_weight(field: &Ident) -> TokenStream2 {
quote_spanned! { field.span() =>
&if self.#field.ref_time() > 1_000_000_000 {
format!(
"{:.1?} ms",
Fixed::saturating_from_rational(self.#field.ref_time(), 1_000_000_000).to_float()
"{:.1?} ms, {} bytes",
Fixed::saturating_from_rational(self.#field.ref_time(), 1_000_000_000).to_float(),
self.#field.proof_size()
)
} else if self.#field.ref_time() > 1_000_000 {
format!(
"{:.1?} µs",
Fixed::saturating_from_rational(self.#field.ref_time(), 1_000_000).to_float()
"{:.1?} µs, {} bytes",
Fixed::saturating_from_rational(self.#field.ref_time(), 1_000_000).to_float(),
self.#field.proof_size()
)
} else if self.#field.ref_time() > 1_000 {
format!(
"{:.1?} ns",
Fixed::saturating_from_rational(self.#field.ref_time(), 1_000).to_float()
"{:.1?} ns, {} bytes",
Fixed::saturating_from_rational(self.#field.ref_time(), 1_000).to_float(),
self.#field.proof_size()
)
} else {
format!("{} ps", self.#field.ref_time())
format!("{} ps, {} bytes", self.#field.ref_time(), self.#field.proof_size())
}
}
}