mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 10:27:59 +00:00
Add benchmark machine placeholder (#11198)
* Move new_rng to shared code Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add bechmark machine command Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Use sc-sysinfo Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add --no-hardware-benchmarks Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Lockfile Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Do not create components if not needed Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fix tests Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Revert "Add --no-hardware-benchmarks" This reverts commit d4ee98222bf1a5ea62ac60dd7d5c62070e2d7f70. * Fix tests Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Update Cargo deps Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Move sr255119::verify bench to sc-sysinfo Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Move sr255119::verify bench to sc-sysinfo Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Switch benchmarks to return f64 Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Review fixes Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * fmt Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Hide command until completed Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Use concrete rand implementation Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Put clobber into a function Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add test Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add comment Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Update cargo to match polkadot Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Remove doc that does not format in the console Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Limit benchmark by time Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add ExecutionLimit and make function infallible Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * CI Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add doc Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
This commit is contained in:
committed by
GitHub
parent
ae75a371bf
commit
362dc50940
@@ -20,12 +20,16 @@
|
||||
//! and software telemetry information about the node on which we're running.
|
||||
|
||||
use futures::prelude::*;
|
||||
use std::time::Duration;
|
||||
|
||||
mod sysinfo;
|
||||
#[cfg(target_os = "linux")]
|
||||
mod sysinfo_linux;
|
||||
|
||||
pub use sysinfo::{gather_hwbench, gather_sysinfo};
|
||||
pub use sysinfo::{
|
||||
benchmark_cpu, benchmark_disk_random_writes, benchmark_disk_sequential_writes,
|
||||
benchmark_memory, benchmark_sr25519_verify, gather_hwbench, gather_sysinfo,
|
||||
};
|
||||
|
||||
/// The operating system part of the current target triplet.
|
||||
pub const TARGET_OS: &str = include_str!(concat!(env!("OUT_DIR"), "/target_os.txt"));
|
||||
@@ -49,6 +53,38 @@ pub struct HwBench {
|
||||
pub disk_random_write_score: Option<u64>,
|
||||
}
|
||||
|
||||
/// Limit the execution time of a benchmark.
|
||||
pub enum ExecutionLimit {
|
||||
/// Limit by the maximal duration.
|
||||
MaxDuration(Duration),
|
||||
|
||||
/// Limit by the maximal number of iterations.
|
||||
MaxIterations(usize),
|
||||
|
||||
/// Limit by the maximal duration and maximal number of iterations.
|
||||
Both { max_iterations: usize, max_duration: Duration },
|
||||
}
|
||||
|
||||
impl ExecutionLimit {
|
||||
/// Returns the duration limit or `MAX` if none is present.
|
||||
pub fn max_duration(&self) -> Duration {
|
||||
match self {
|
||||
Self::MaxDuration(d) => *d,
|
||||
Self::Both { max_duration, .. } => *max_duration,
|
||||
_ => Duration::from_secs(u64::MAX),
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the iterations limit or `MAX` if none is present.
|
||||
pub fn max_iterations(&self) -> usize {
|
||||
match self {
|
||||
Self::MaxIterations(d) => *d,
|
||||
Self::Both { max_iterations, .. } => *max_iterations,
|
||||
_ => usize::MAX,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Prints out the system software/hardware information in the logs.
|
||||
pub fn print_sysinfo(sysinfo: &sc_telemetry::SysInfo) {
|
||||
log::info!("💻 Operating system: {}", TARGET_OS);
|
||||
|
||||
Reference in New Issue
Block a user