[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 authored and GitHub committed 2023-01-25 15:12:29 -03:00
1 parent 3b03862caf
commit 2a38f4122a
3 files changed
+16 -13

No files matched your search

@@ -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())
}
}
}