-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[benchmarking-cli] Add --keys-limit=Option<usize> and --random-seed=Option<u64>
#10884
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 3 commits
407791a
f427cd3
ed30217
35837c3
6ed88c4
6960e54
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -159,6 +159,16 @@ pub struct StorageParams { | |
| /// This is only used when `mode` is `validate-block`. | ||
| #[arg(long, default_value_t = 20)] | ||
| pub validate_block_rounds: u32, | ||
|
|
||
| /// Maximum number of keys to read | ||
| /// (All keys if not define) | ||
| #[arg(long)] | ||
| pub keys_limit: Option<usize>, | ||
|
|
||
| /// Seed to use for benchs randomness, the same seed allow to replay | ||
| /// becnhamrks under the same conditions. | ||
arturgontijo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| #[arg(long)] | ||
| pub random_seed: Option<u64>, | ||
| } | ||
|
|
||
| impl StorageParams { | ||
|
|
@@ -248,8 +258,17 @@ impl StorageCmd { | |
| BA: ClientBackend<B>, | ||
| { | ||
| let hash = client.usage_info().chain.best_hash; | ||
| let mut keys: Vec<_> = client.storage_keys(hash, None, None)?.collect(); | ||
| let (mut rng, _) = new_rng(None); | ||
| let mut keys: Vec<_> = if let Some(keys_limit) = self.params.keys_limit { | ||
| use sp_core::blake2_256; | ||
| let first_key = self | ||
| .params | ||
| .random_seed | ||
| .map(|seed| sp_storage::StorageKey(blake2_256(&seed.to_be_bytes()[..]).to_vec())); | ||
|
||
| client.storage_keys(hash, None, first_key.as_ref())?.take(keys_limit).collect() | ||
| } else { | ||
| client.storage_keys(hash, None, None)?.collect() | ||
| }; | ||
| let (mut rng, _) = new_rng(self.params.random_seed); | ||
| keys.shuffle(&mut rng); | ||
|
|
||
| for i in 0..self.params.warmups { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.