Add verify block to benchmark tests (#5551)

* Add verify block to benchmarks macro.

* Update all benchmarks.

* Add tests, add params.

* Should panic.

* ups, add closures

* Update tests.rs

* update macro syntax

* Revert benchmark syntax change

* verify only in tests

* Update tests.rs

* Uncomment staking

* Fix tests for benchmark instance

* Add docs

* Update frame/benchmarking/src/lib.rs

* add trace logs to benchmarks

* Verify returns closure

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
This commit is contained in:
Marcio Diaz
2020-04-08 12:55:06 +02:00
committed by GitHub
parent c73398ab03
commit 7cc095ec9f
6 changed files with 332 additions and 70 deletions
+8 -2
View File
@@ -113,8 +113,11 @@ pub trait BenchmarkingSetup<T> {
/// Return the components and their ranges which should be tested in this benchmark.
fn components(&self) -> Vec<(BenchmarkParameter, u32, u32)>;
/// Set up the storage, and prepare a closure to test in a single run of the benchmark.
/// Set up the storage, and prepare a closure to run the benchmark.
fn instance(&self, components: &[(BenchmarkParameter, u32)]) -> Result<Box<dyn FnOnce() -> Result<(), &'static str>>, &'static str>;
/// Set up the storage, and prepare a closure to test and verify the benchmark
fn verify(&self, components: &[(BenchmarkParameter, u32)]) -> Result<Box<dyn FnOnce() -> Result<(), &'static str>>, &'static str>;
}
/// The required setup for creating a benchmark.
@@ -122,8 +125,11 @@ pub trait BenchmarkingSetupInstance<T, I> {
/// Return the components and their ranges which should be tested in this benchmark.
fn components(&self) -> Vec<(BenchmarkParameter, u32, u32)>;
/// Set up the storage, and prepare a closure to test in a single run of the benchmark.
/// Set up the storage, and prepare a closure to run the benchmark.
fn instance(&self, components: &[(BenchmarkParameter, u32)]) -> Result<Box<dyn FnOnce() -> Result<(), &'static str>>, &'static str>;
/// Set up the storage, and prepare a closure to test and verify the benchmark
fn verify(&self, components: &[(BenchmarkParameter, u32)]) -> Result<Box<dyn FnOnce() -> Result<(), &'static str>>, &'static str>;
}
/// Grab an account, seeded by a name and index.