From c9f4533b4c695dfa745c98de348db9c7bdfc8502 Mon Sep 17 00:00:00 2001 From: rainbow-promise Date: Sun, 24 Nov 2024 20:52:33 -0800 Subject: [PATCH 1/2] initialize doc directory --- docs/sdk/src/reference_docs/frame_omni_bencher/Cargo.toml | 0 docs/sdk/src/reference_docs/frame_omni_bencher/tests.rs | 5 +++++ 2 files changed, 5 insertions(+) create mode 100644 docs/sdk/src/reference_docs/frame_omni_bencher/Cargo.toml create mode 100644 docs/sdk/src/reference_docs/frame_omni_bencher/tests.rs diff --git a/docs/sdk/src/reference_docs/frame_omni_bencher/Cargo.toml b/docs/sdk/src/reference_docs/frame_omni_bencher/Cargo.toml new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/docs/sdk/src/reference_docs/frame_omni_bencher/tests.rs b/docs/sdk/src/reference_docs/frame_omni_bencher/tests.rs new file mode 100644 index 000000000000..93f81d40c289 --- /dev/null +++ b/docs/sdk/src/reference_docs/frame_omni_bencher/tests.rs @@ -0,0 +1,5 @@ +use serde_json::{json, Value}; +use std::{process::Command, str}; + +const WASM_FILE_PATH: &str = + "../../../../../target/release/wbuild/westend-runtime/westend-runtime-compact-compressed.wasm"; \ No newline at end of file From e3e3df7d5d5c6b8164ba1b5c28eabb1ed4d01d53 Mon Sep 17 00:00:00 2001 From: rainbow-promise Date: Mon, 25 Nov 2024 09:24:56 -0800 Subject: [PATCH 2/2] init --- Cargo.toml | 1 + docs/sdk/Cargo.toml | 1 + .../frame_omni_bencher/Cargo.toml | 13 +++++ .../frame_omni_bencher/tests.rs | 54 ++++++++++++++++++- 4 files changed, 67 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 533ea4c9e878..384312864d41 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -678,6 +678,7 @@ cfg-expr = { version = "0.15.5" } cfg-if = { version = "1.0" } chain-spec-builder = { path = "substrate/bin/utils/chain-spec-builder", default-features = false, package = "staging-chain-spec-builder" } chain-spec-guide-runtime = { path = "docs/sdk/src/reference_docs/chain_spec_runtime" } +frame-omni-bencher-guide = { path = "docs/sdk/src/reference_docs/frame-omni-bencher" } chrono = { version = "0.4.31" } cid = { version = "0.9.0" } clap = { version = "4.5.13" } diff --git a/docs/sdk/Cargo.toml b/docs/sdk/Cargo.toml index 0c39367eeed3..232c7a7055e6 100644 --- a/docs/sdk/Cargo.toml +++ b/docs/sdk/Cargo.toml @@ -126,6 +126,7 @@ pallet-xcm = { workspace = true } # runtime guides chain-spec-guide-runtime = { workspace = true, default-features = true } +frame-omni-bencher-guide = { workspace = true, default-features = true } # Templates minimal-template-runtime = { workspace = true, default-features = true } diff --git a/docs/sdk/src/reference_docs/frame_omni_bencher/Cargo.toml b/docs/sdk/src/reference_docs/frame_omni_bencher/Cargo.toml index e69de29bb2d1..2754b3509797 100644 --- a/docs/sdk/src/reference_docs/frame_omni_bencher/Cargo.toml +++ b/docs/sdk/src/reference_docs/frame_omni_bencher/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "frame-omni-bencher-guide" +description = "A frame-omni-bencher guide" +version = "0.0.0" +license = "MIT-0" +authors.workspace = true +homepage.workspace = true +repository.workspace = true +edition.workspace = true +publish = false + +[dependencies] +docify = { workspace = true } \ No newline at end of file diff --git a/docs/sdk/src/reference_docs/frame_omni_bencher/tests.rs b/docs/sdk/src/reference_docs/frame_omni_bencher/tests.rs index 93f81d40c289..ebb668f1e284 100644 --- a/docs/sdk/src/reference_docs/frame_omni_bencher/tests.rs +++ b/docs/sdk/src/reference_docs/frame_omni_bencher/tests.rs @@ -1,5 +1,55 @@ -use serde_json::{json, Value}; use std::{process::Command, str}; const WASM_FILE_PATH: &str = - "../../../../../target/release/wbuild/westend-runtime/westend-runtime-compact-compressed.wasm"; \ No newline at end of file + "../../../../../target/release/wbuild/westend-runtime/westend-runtime-compact-compressed.wasm"; + +const FRAME_OMNI_BENCHER_PATH: &str = "../../../../../target/release/frame-omni-bencher"; + + +fn install_frame_omni_bencher() -> &'static str { + let _ = std::process::Command::new("cargo") + .arg("build") + .arg("-p") + .arg("frame-omni-bencher") + .arg("--release") + .status() + .expect("Failed to execute command"); + WASM_FILE_PATH +} + +fn build_westend_runtime() -> &'static str { + let _ = std::process::Command{"cargo"} + .arg("build") + .arg("--release") + .arg("-p") + .arg("westend-runtime") + .arg("--features") + .arg("runtime-benchmarks") + .arg("--release") + .status() + .expect("Failed to execute command"); + WASM_FILE_PATH +} + +fn pallet_utility_bench(wasm_file_path: &'static str, frame_omni_bencher_path: &'static str) { + + let _ = std::process::Command::new(frame_omni_bencher_path) + .arg("v1") + .arg("benchmark") + .arg("pallet") + .arg("--runtime") + .arg(wasm_file_path) + .arg("--pallet") + .arg("pallet-utility") + .arg("--extrinsic") + .arg("") + .expect("Failed to execute"); +} + +#[test] +#[docify::export] +fn test_pallet_utility_bench() { + let output_2 = Command::new(install_frame_omni_bencher()); + let output_1 = Command::new(build_westend_runtime()); + let _ = Command::new(pallet_utility_bench(output_1, output_2)); +} \ No newline at end of file