Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
7b33492
Starting
shawntabrizi Jan 16, 2020
3b12740
closer
shawntabrizi Jan 21, 2020
55cf8b6
Compiles!
shawntabrizi Jan 21, 2020
9da52bb
comments
shawntabrizi Jan 21, 2020
27127c0
Create seperate mock
shawntabrizi Jan 21, 2020
ae84e9f
Remove changes to test env
shawntabrizi Jan 21, 2020
06d1173
Fix step calculation
shawntabrizi Jan 21, 2020
9f25cf5
Add host function
shawntabrizi Jan 22, 2020
621cc0d
Merge remote-tracking branch 'upstream/master' into shawntabrizi-iden…
shawntabrizi Jan 22, 2020
ddff026
Add runtime api
shawntabrizi Jan 22, 2020
b32c805
Merge remote-tracking branch 'upstream/master' into shawntabrizi-iden…
shawntabrizi Jan 22, 2020
890ad0d
compiles
shawntabrizi Jan 22, 2020
0a1bcfc
Update to use offchain timestamp
shawntabrizi Jan 23, 2020
931702b
Gives a result
shawntabrizi Jan 27, 2020
e8c4992
added some CLI wip
shawntabrizi Jan 28, 2020
334d1e6
Merge branch 'master' of github.com:paritytech/substrate into shawnta…
arkpar Jan 28, 2020
e5657e9
make generic
shawntabrizi Jan 28, 2020
32e9e07
Update instance
shawntabrizi Jan 28, 2020
1e2630c
Remove CLI stuff
shawntabrizi Jan 28, 2020
bafbac0
Remove last cli stuff
shawntabrizi Jan 28, 2020
86b32ef
undo more changes
shawntabrizi Jan 28, 2020
dd87c93
Update benchmarks
shawntabrizi Jan 29, 2020
6814c1a
Merge remote-tracking branch 'upstream/master' into shawntabrizi-iden…
shawntabrizi Jan 29, 2020
7c089f7
Update Cargo.lock
shawntabrizi Jan 29, 2020
7bd0ae1
remove test
shawntabrizi Jan 29, 2020
862dc67
Move loop out of runtime
shawntabrizi Jan 30, 2020
6d0c8b4
Benchmarking externalities
arkpar Feb 3, 2020
1575aae
Merge branch 'shawntabrizi-identity-bench' of github.com:paritytech/s…
arkpar Feb 3, 2020
3c5dcf7
Benchmarking state
arkpar Feb 3, 2020
d7c0ae8
Implemented commit
arkpar Feb 3, 2020
38602b8
Make CLI work, move loop back into runtime
shawntabrizi Feb 4, 2020
9614ea7
Merge branch 'master' of github.com:paritytech/substrate into shawnta…
arkpar Feb 4, 2020
e6eeab8
Merge branch 'shawntabrizi-identity-bench' of github.com:paritytech/s…
arkpar Feb 4, 2020
5ee888f
Wipe resets to genesis
arkpar Feb 4, 2020
e0b48d2
Merge branch 'master' of github.com:paritytech/substrate into shawnta…
arkpar Feb 5, 2020
d73ca25
Speedup benchmarks
arkpar Feb 5, 2020
879826c
Use enum to select extrinsic within pallet
shawntabrizi Feb 5, 2020
e041347
CLI controls which module and extrinsic to call
shawntabrizi Feb 5, 2020
115290b
Select a pallet with cli
shawntabrizi Feb 5, 2020
283860c
Add steps and repeats to cli
shawntabrizi Feb 5, 2020
978a1b4
Merge branch 'shawntabrizi-identity-bench' of https://github.com/pari…
shawntabrizi Feb 6, 2020
ca890f6
Output as CSV format
shawntabrizi Feb 6, 2020
1cb8529
Introduce benchmark pallet
shawntabrizi Feb 6, 2020
1c97bd9
Append bench
shawntabrizi Feb 7, 2020
ea5c3e1
Use Results
shawntabrizi Feb 7, 2020
94bff4b
Merge remote-tracking branch 'upstream/master' into shawntabrizi-iden…
shawntabrizi Feb 7, 2020
55a2e85
fix merge
shawntabrizi Feb 7, 2020
6787808
Clear Identity benchmark
shawntabrizi Feb 7, 2020
4c2b218
Bench request judgment and cancel request
shawntabrizi Feb 8, 2020
833c377
Add final benchmarks
shawntabrizi Feb 8, 2020
3e27b42
Fix CSV output
shawntabrizi Feb 8, 2020
34838f6
Start cleaning up for PR
shawntabrizi Feb 8, 2020
93422d4
Bump numbers in `wasmtime` integration tests.
shawntabrizi Feb 8, 2020
6bcf639
Merge remote-tracking branch 'upstream/master' into shawntabrizi-iden…
shawntabrizi Feb 8, 2020
f73ca4a
More docs
shawntabrizi Feb 8, 2020
eecaac0
Add rockdb feature to bench
shawntabrizi Feb 8, 2020
6243911
Fix formatting issues
shawntabrizi Feb 8, 2020
09804e1
Add test feature to bench
shawntabrizi Feb 9, 2020
00809ad
Add test feature to bench
shawntabrizi Feb 9, 2020
8d509d0
Add rocksdb feature flag
shawntabrizi Feb 9, 2020
fe2d0a2
Update bench.rs
gavofyork Feb 9, 2020
91827e5
Merge branch 'master' into shawntabrizi-identity-bench
gavofyork Feb 10, 2020
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
Prev Previous commit
Next Next commit
closer
  • Loading branch information
shawntabrizi committed Jan 21, 2020
commit 3b12740a15e7ce364745fe0cbfd9a6fc8de4bd06
87 changes: 78 additions & 9 deletions frame/identity/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -862,9 +862,17 @@ decl_module! {
}
}

mod benchmarking {
mod set_identity {
fn components() -> Vec<(&'static str, u32, u32)> {
#[cfg(test)]
pub mod benchmarking {

pub mod set_identity {
use crate::*;
use crate::tests::*;
use frame_support::{
assert_ok
};

pub fn components() -> Vec<(&'static str, u32, u32)> {
vec![
// Registrar Count
("R", 1, 16),
Expand All @@ -880,16 +888,69 @@ mod benchmarking {
///
/// Sets up state randomly and returns a randomly generated `set_identity` with sensible (fixed)
/// values for all complexity components except those mentioned in the identity.
fn instance(components: &[(&'static str, u32)]) -> Call {
Call::set_identity::default()
fn instance(components: &[(&'static str, u32)]) -> Call<Test>
{
// Add r registrars
let r = components.iter().find(|&c| c.0 == "R").unwrap();
for i in 0..r.1 {
assert_ok!(Identity::add_registrar(Origin::signed(1), i.into()));
assert_ok!(Identity::set_fee(Origin::signed(i.into()), 0, 10));
let fields = IdentityFields(IdentityField::Display | IdentityField::Legal);
assert_ok!(Identity::set_fields(Origin::signed(i.into()), 0, fields));
}

// Create identity info with x additional fields
let x = components.iter().find(|&c| c.0 == "R").unwrap();
let data = Data::Raw(vec![0; x.1 as usize]);
let info = IdentityInfo {
additional: vec![(data.clone(), data.clone()); 3],
display: data.clone(),
legal: data.clone(),
web: data.clone(),
riot: data.clone(),
email: data.clone(),
pgp_fingerprint: Some([0; 20]),
image: data.clone(),
twitter: data.clone(),
};

// Return the `set_identity` call
return Call::set_identity(info)
}
}
}

#[cfg(test)]
impl<T: Trait> Benchmarking for Module<T> {
type BenchmarkResults = bool;
const STEPS: usize = 100;
const REPEATS: usize = 10;

fn run_benchmarks() -> Vec<Self::BenchmarkResults> {
return vec![true]
// first one is set_identity.
let components = benchmarking::set_identity::components();
for (i, (name, low, high)) in components.iter().enumerate() {
for j in 0..STEPS {
let step = j * (high - low) / 100 + low;


let c = components.iter().enumerate()
.map(|(j, (n, low, high))|
(n, if x == y { step } else { (high - low) / 2 + low })
).collect();


// for x in 0..REPEATS {
// let instance = set_identity::instance(&c);
// timer.begin();
// assert_ok!(instance.dispatch());
// let t = timer.elapsed();
// BenchmarkResults.calls["set_identity"].push((c, t));
// }
// }
// }
// }
return vec![true];
}
}

Expand All @@ -900,7 +961,7 @@ pub mod tests {
use sp_runtime::traits::BadOrigin;
use frame_support::{
assert_ok, assert_noop, impl_outer_origin, parameter_types, weights::Weight,
ord_parameter_types
ord_parameter_types, impl_outer_dispatch,
};
use sp_core::H256;
use frame_system::EnsureSignedBy;
Expand All @@ -914,6 +975,14 @@ pub mod tests {
pub enum Origin for Test where system = frame_system {}
}

impl_outer_dispatch! {
pub enum Call for Test where origin: Origin {
frame_system::System,
pallet_balances::Balances,
pallet_identity::Identity,
}
}

// For testing the module, we construct most of a mock runtime. This means
// first constructing a configuration type (`Test`) which `impl`s each of the
// configuration traits of modules we want to use.
Expand All @@ -930,7 +999,7 @@ pub mod tests {
type Index = u64;
type BlockNumber = u64;
type Hash = H256;
type Call = ();
type Call = Call;
type Hashing = BlakeTwo256;
type AccountId = u64;
type Lookup = IdentityLookup<Self::AccountId>;
Expand Down Expand Up @@ -983,7 +1052,7 @@ pub mod tests {
}
type System = frame_system::Module<Test>;
type Balances = pallet_balances::Module<Test>;
type Identity = Module<Test>;
pub type Identity = Module<Test>;

// This function basically just builds a genesis storage key/value store according to
// our desired mockup.
Expand Down
4 changes: 4 additions & 0 deletions primitives/runtime/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1267,6 +1267,10 @@ pub trait BlockIdTo<Block: self::Block> {
pub trait Benchmarking {
/// Type for the results of benchmarks.
type BenchmarkResults;
/// Number of steps to take between variable ranges.
const STEPS: usize;
/// Number of benchmarking repetitions.
const REPEATS: usize;
/// Run the benchmarks for this module.
fn run_benchmarks() -> Vec<Self::BenchmarkResults>;
}
Expand Down