Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Use temporary db for benchmarking #12254

Merged
merged 6 commits into from
Sep 20, 2022
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions utils/frame/benchmarking-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub use extrinsic::{ExtrinsicBuilder, ExtrinsicCmd, ExtrinsicFactory};
pub use machine::{MachineCmd, Requirements, SUBSTRATE_REFERENCE_HARDWARE};
pub use overhead::OverheadCmd;
pub use pallet::PalletCmd;
pub use sc_service::BasePath;
pub use storage::StorageCmd;

use sc_cli::{CliConfiguration, DatabaseParams, ImportParams, PruningParams, Result, SharedParams};
Expand Down Expand Up @@ -87,6 +88,19 @@ impl CliConfiguration for BenchmarkCmd {
}
}

fn base_path(&self) -> Result<Option<BasePath>> {
let inner = unwrap_cmd! {
self, cmd, cmd.base_path()
};

//If the base path was not provided, benchmark command shall use temporary path. Otherwise
//we may end up using shared path, which may be inappropriate for benchmarking.
bkchr marked this conversation as resolved.
Show resolved Hide resolved
match inner {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comment on why we are doing this would be nice.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Ok(None) => Some(BasePath::new_temp_dir()).transpose().map_err(|e| e.into()),
e => e,
}
}

fn pruning_params(&self) -> Option<&PruningParams> {
unwrap_cmd! {
self, cmd, cmd.pruning_params()
Expand Down