-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: skeleton code for storage benchmarking
- Loading branch information
1 parent
d08a749
commit 4cf733c
Showing
4 changed files
with
59 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
use crate::{ | ||
cli::{self}, | ||
common::prompt::display_message, | ||
}; | ||
use clap::Args; | ||
use frame_benchmarking_cli::StorageCmd; | ||
use pop_parachains::generate_storage_benchmarks; | ||
|
||
#[derive(Args)] | ||
pub struct BenchmarkStorage { | ||
#[clap(flatten)] | ||
pub command: StorageCmd, | ||
|
||
/// If this is set to true, no interactive prompts will be shown. | ||
#[clap(short = 'i', long)] | ||
pub skip_all: bool, | ||
} | ||
|
||
impl BenchmarkStorage { | ||
pub(crate) async fn execute(&mut self, cli: &mut impl cli::traits::Cli) -> anyhow::Result<()> { | ||
cli.intro("Benchmarking the storage speed of a chain snapshot")?; | ||
|
||
cli.warning("NOTE: this may take some time...")?; | ||
cli.info("Benchmarking and generating weight file...")?; | ||
|
||
if let Err(e) = self.run().await { | ||
return display_message(&e.to_string(), false, cli); | ||
} | ||
display_message("Benchmark completed successfully!", true, cli)?; | ||
Ok(()) | ||
} | ||
|
||
async fn run(&self) -> anyhow::Result<()> { | ||
generate_storage_benchmarks(StorageCmd { | ||
shared_params: self.command.shared_params.clone(), | ||
database_params: self.command.database_params.clone(), | ||
pruning_params: self.command.pruning_params.clone(), | ||
params: self.command.params.clone(), | ||
}) | ||
.await | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters