Some benchmarks for phragmen (#2650)

* Add some benchmarks for phragmen

* Fix dep. import.

* Clean up with some macros.

* more details.

* Fix dual import.

* Remove wrong assertions.

* Add a few more.
This commit is contained in:
Kian Peymani
2019-06-05 11:42:29 +02:00
committed by Gavin Wood
parent 012ce5878b
commit a5964e4055
7 changed files with 193 additions and 74 deletions
+20 -9
View File
@@ -240,16 +240,31 @@
//! stored in the Session module's `Validators` at the end of each era.
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(all(feature = "bench", test), feature(test))]
#[cfg(all(feature = "bench", test))]
extern crate test;
#[cfg(any(feature = "bench", test))]
mod mock;
#[cfg(test)]
mod tests;
mod phragmen;
#[cfg(all(feature = "bench", test))]
mod benches;
#[cfg(feature = "std")]
use runtime_io::with_storage;
use rstd::{prelude::*, result, collections::btree_map::BTreeMap};
use parity_codec::{HasCompact, Encode, Decode};
use srml_support::{StorageValue, StorageMap, EnumerableStorageMap, dispatch::Result};
use srml_support::{decl_module, decl_event, decl_storage, ensure};
use srml_support::traits::{
Currency, OnFreeBalanceZero, OnDilution, LockIdentifier, LockableCurrency, WithdrawReasons,
OnUnbalanced, Imbalance,
use srml_support::{ StorageValue, StorageMap, EnumerableStorageMap, dispatch::Result,
decl_module, decl_event, decl_storage, ensure,
traits::{Currency, OnFreeBalanceZero, OnDilution, LockIdentifier, LockableCurrency,
WithdrawReasons, OnUnbalanced, Imbalance
}
};
use session::OnSessionChange;
use primitives::Perbill;
@@ -261,10 +276,6 @@ use primitives::traits::{
use primitives::{Serialize, Deserialize};
use system::ensure_signed;
mod mock;
mod tests;
mod phragmen;
use phragmen::{elect, ACCURACY, ExtendedBalance};
const RECENT_OFFLINE_COUNT: usize = 32;