This repository was archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Spellcheck HBS templates and add test #11119
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7314bd9
Spellcheck HBS templates and fix vars
ggwpez cd2692f
Add test for benchmark-storage
ggwpez 75781f9
Fmt templates
ggwpez c5f6b29
fmt
ggwpez dd6b843
Merge remote-tracking branch 'origin/master' into oty-hbs-spellcheck
ggwpez 7ef960e
Review fixes
ggwpez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,52 @@ | ||
| // This file is part of Substrate. | ||
|
|
||
| // Copyright (C) 2022 Parity Technologies (UK) Ltd. | ||
| // SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 | ||
|
|
||
| // This program is free software: you can redistribute it and/or modify | ||
| // it under the terms of the GNU General Public License as published by | ||
| // the Free Software Foundation, either version 3 of the License, or | ||
| // (at your option) any later version. | ||
|
|
||
| // This program is distributed in the hope that it will be useful, | ||
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| // GNU General Public License for more details. | ||
|
|
||
| // You should have received a copy of the GNU General Public License | ||
| // along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
|
||
| use assert_cmd::cargo::cargo_bin; | ||
| use std::{ | ||
| path::Path, | ||
| process::{Command, ExitStatus}, | ||
| }; | ||
| use tempfile::tempdir; | ||
|
|
||
| /// Tests that the `benchmark-storage` command works for the dev runtime. | ||
| #[test] | ||
| fn benchmark_storage_works() { | ||
| let tmp_dir = tempdir().expect("could not create a temp dir"); | ||
| let base_path = tmp_dir.path(); | ||
|
|
||
| // Benchmarking the storage works and creates the correct weight file. | ||
| assert!(benchmark_storage("rocksdb", base_path).success()); | ||
| assert!(base_path.join("rocksdb_weights.rs").exists()); | ||
|
|
||
| assert!(benchmark_storage("paritydb", base_path).success()); | ||
| assert!(base_path.join("paritydb_weights.rs").exists()); | ||
| } | ||
|
|
||
| fn benchmark_storage(db: &str, base_path: &Path) -> ExitStatus { | ||
| Command::new(cargo_bin("substrate")) | ||
| .args(&["benchmark-storage", "--dev"]) | ||
| .arg("--db") | ||
| .arg(db) | ||
| .arg("--weight-path") | ||
| .arg(base_path) | ||
| .args(["--state-version", "1"]) | ||
| .args(["--warmups", "0"]) | ||
| .args(["--add", "100", "--mul", "1.2", "--metric", "p75"]) | ||
| .status() | ||
| .unwrap() | ||
| } |
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -37,17 +37,17 @@ parameter_types! { | |
| {{#if (eq short_name "block")}} | ||
| /// Time to execute an empty block. | ||
| {{else}} | ||
| /// Time to execute a NO-OP extrinsic eg. `System::remark`. | ||
| /// Time to execute a NO-OP extrinsic, for example `System::remark`. | ||
| {{/if}} | ||
| /// Calculated by multiplying the *{{params.weight.weight_metric}}* with `{{params.weight.weight_mul}}` and adding `{{params.weight.weight_add}}`. | ||
| /// | ||
| /// Stats [ns]: | ||
| /// Stats [NS]: | ||
| /// Min, Max: {{underscore stats.min}}, {{underscore stats.max}} | ||
| /// Average: {{underscore stats.avg}} | ||
| /// Median: {{underscore stats.median}} | ||
| /// StdDev: {{stats.stddev}} | ||
| /// Std-Dev: {{stats.stddev}} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CC |
||
| /// | ||
| /// Percentiles [ns]: | ||
| /// Percentiles [NS]: | ||
| /// 99th: {{underscore stats.p99}} | ||
| /// 95th: {{underscore stats.p95}} | ||
| /// 75th: {{underscore stats.p75}} | ||
|
|
@@ -67,26 +67,14 @@ mod test_weights { | |
|
|
||
| {{#if (eq short_name "block")}} | ||
| // At least 100 µs. | ||
| assert!( | ||
| w >= 100 * constants::WEIGHT_PER_MICROS, | ||
| "Weight should be at least 100 µs." | ||
| ); | ||
| assert!(w >= 100 * constants::WEIGHT_PER_MICROS, "Weight should be at least 100 µs."); | ||
| // At most 50 ms. | ||
| assert!( | ||
| w <= 50 * constants::WEIGHT_PER_MILLIS, | ||
| "Weight should be at most 50 ms." | ||
| ); | ||
| assert!(w <= 50 * constants::WEIGHT_PER_MILLIS, "Weight should be at most 50 ms."); | ||
| {{else}} | ||
| // At least 10 µs. | ||
| assert!( | ||
| w >= 10 * constants::WEIGHT_PER_MICROS, | ||
| "Weight should be at least 10 µs." | ||
| ); | ||
| assert!(w >= 10 * constants::WEIGHT_PER_MICROS, "Weight should be at least 10 µs."); | ||
| // At most 1 ms. | ||
| assert!( | ||
| w <= constants::WEIGHT_PER_MILLIS, | ||
| "Weight should be at most 1 ms." | ||
| ); | ||
| assert!(w <= constants::WEIGHT_PER_MILLIS, "Weight should be at most 1 ms."); | ||
| {{/if}} | ||
| } | ||
| } | ||
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Iiuc this is nanoseconds, correct? If so, we should add this as a whitelist item in the
spellcheck.confrather than adjusting the case.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep. Having some of these whitelisted would be nice 🙏
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding something like https://github.com/paritytech/polkadot/blob/master/scripts/gitlab/spellcheck.toml with https://github.com/paritytech/polkadot/blob/master/scripts/gitlab/lingua.dic