Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
open-runtime-module-library
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Noxim
open-runtime-module-library
Commits
18309c93
Unverified
Commit
18309c93
authored
4 years ago
by
Shaopeng Wang
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Update benchmarking macro. (#259)
parent
0cb94a5a
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
benchmarking/Cargo.toml
+3
-0
3 additions, 0 deletions
benchmarking/Cargo.toml
benchmarking/src/lib.rs
+23
-15
23 additions, 15 deletions
benchmarking/src/lib.rs
with
26 additions
and
15 deletions
benchmarking/Cargo.toml
+
3
−
0
View file @
18309c93
...
@@ -19,6 +19,9 @@ frame-support = { version = "2.0.0-rc6", default-features = false }
...
@@ -19,6 +19,9 @@ frame-support = { version = "2.0.0-rc6", default-features = false }
frame-system
=
{
version
=
"2.0.0-rc6"
,
default-features
=
false
}
frame-system
=
{
version
=
"2.0.0-rc6"
,
default-features
=
false
}
frame-benchmarking
=
{
version
=
"2.0.0-rc6"
,
default-features
=
false
}
frame-benchmarking
=
{
version
=
"2.0.0-rc6"
,
default-features
=
false
}
[dev-dependencies]
hex-literal
=
"0.2.1"
[features]
[features]
default
=
[
"std"
]
default
=
[
"std"
]
std
=
[
std
=
[
...
...
This diff is collapsed.
Click to expand it.
benchmarking/src/lib.rs
+
23
−
15
View file @
18309c93
...
@@ -7,6 +7,7 @@ mod tests;
...
@@ -7,6 +7,7 @@ mod tests;
pub
use
frame_benchmarking
::{
pub
use
frame_benchmarking
::{
benchmarking
,
BenchmarkBatch
,
BenchmarkParameter
,
BenchmarkResults
,
Benchmarking
,
BenchmarkingSetup
,
benchmarking
,
BenchmarkBatch
,
BenchmarkParameter
,
BenchmarkResults
,
Benchmarking
,
BenchmarkingSetup
,
TrackedStorageKey
,
};
};
#[cfg(feature
=
"std"
)]
#[cfg(feature
=
"std"
)]
pub
use
frame_benchmarking
::{
Analysis
,
BenchmarkSelector
};
pub
use
frame_benchmarking
::{
Analysis
,
BenchmarkSelector
};
...
@@ -718,7 +719,7 @@ macro_rules! impl_benchmark {
...
@@ -718,7 +719,7 @@ macro_rules! impl_benchmark {
highest_range_values
:
&
[
u32
],
highest_range_values
:
&
[
u32
],
steps
:
&
[
u32
],
steps
:
&
[
u32
],
repeat
:
u32
,
repeat
:
u32
,
whitelist
:
&
[
Vec
<
u8
>
]
whitelist
:
&
[
$crate
::
TrackedStorageKey
]
)
->
Result
<
Vec
<
$crate
::
BenchmarkResults
>
,
&
'static
str
>
{
)
->
Result
<
Vec
<
$crate
::
BenchmarkResults
>
,
&
'static
str
>
{
// Map the input to the selected benchmark.
// Map the input to the selected benchmark.
let
extrinsic
=
sp_std
::
str
::
from_utf8
(
extrinsic
)
let
extrinsic
=
sp_std
::
str
::
from_utf8
(
extrinsic
)
...
@@ -757,8 +758,8 @@ macro_rules! impl_benchmark {
...
@@ -757,8 +758,8 @@ macro_rules! impl_benchmark {
>
::
instance
(
&
selected_benchmark
,
&
c
)
?
;
>
::
instance
(
&
selected_benchmark
,
&
c
)
?
;
// Set the block number to at least 1 so events are deposited.
// Set the block number to at least 1 so events are deposited.
if
$crate
::
Zero
::
is_zero
(
&
frame_system
::
Module
::
<
T
>
::
block_number
())
{
if
$crate
::
Zero
::
is_zero
(
&
frame_system
::
Module
::
<
$runtime
>
::
block_number
())
{
frame_system
::
Module
::
<
T
>
::
set_block_number
(
1u8
.into
());
frame_system
::
Module
::
<
$runtime
>
::
set_block_number
(
1u8
.into
());
}
}
// Commit the externalities to the database, flushing the DB cache.
// Commit the externalities to the database, flushing the DB cache.
...
@@ -937,35 +938,42 @@ macro_rules! impl_benchmark_test {
...
@@ -937,35 +938,42 @@ macro_rules! impl_benchmark_test {
/// let params = (&pallet, &benchmark, &lowest_range_values, &highest_range_values, &steps, repeat, &whitelist);
/// let params = (&pallet, &benchmark, &lowest_range_values, &highest_range_values, &steps, repeat, &whitelist);
/// ```
/// ```
///
///
/// The `whitelist` is a `Vec<Vec<u8>>` of storage keys that you would like to
/// The `whitelist` is a parameter you pass to control the DB read/write
/// skip for DB tracking. For example:
/// tracking. We use a vector of [TrackedStorageKey], which is a simple struct
/// used to set if a key has been read or written to.
///
///
/// ```ignore
/// For values that should be skipped entirely, we can just pass `key.into()`.
/// let whitelist: Vec<Vec<u8>> = vec![
/// For example:
///
/// ```
/// use frame_benchmarking::TrackedStorageKey;
/// use hex_literal;
/// let whitelist: Vec<TrackedStorageKey> = vec![
/// // Block Number
/// // Block Number
/// hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec(),
/// hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec()
.into()
,
/// // Total Issuance
/// // Total Issuance
/// hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec(),
/// hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec()
.into()
,
/// // Execution Phase
/// // Execution Phase
/// hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec(),
/// hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec()
.into()
,
/// // Event Count
/// // Event Count
/// hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec(),
/// hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec()
.into()
,
/// ];
/// ];
/// ```
///
///
/// Then define a mutable local variable to hold your `BenchmarkBatch` object:
/// Then define a mutable local variable to hold your `BenchmarkBatch` object:
/// ```ignore
/// ```ignore
/// let mut batches = Vec::<BenchmarkBatch>::new();
/// let mut batches = Vec::<BenchmarkBatch>::new();
/// ````
/// ````
///
///
/// Then add the pallets you want to benchmark to this object, using their crate
name and generated
/// Then add the pallets you want to benchmark to this object, using their crate
/// module struct:
///
name and generated
module struct:
/// ```ignore
/// ```ignore
/// add_benchmark!(params, batches, pallet_balances, Balances);
/// add_benchmark!(params, batches, pallet_balances, Balances);
/// add_benchmark!(params, batches, pallet_session, SessionBench::<Runtime>);
/// add_benchmark!(params, batches, pallet_session, SessionBench::<Runtime>);
/// add_benchmark!(params, batches, frame_system, SystemBench::<Runtime>);
/// add_benchmark!(params, batches, frame_system, SystemBench::<Runtime>);
/// ...
/// ...
/// ```
/// ```
///
///
/// At the end of `dispatch_benchmark`, you should return this batches object.
/// At the end of `dispatch_benchmark`, you should return this batches object.
#[macro_export]
#[macro_export]
macro_rules!
add_benchmark
{
macro_rules!
add_benchmark
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment