Proper run time format for Monitors
This commit is contained in:
parent
23f02dae12
commit
23b55eae6a
@ -44,6 +44,7 @@ num_cpus = "1.0" # cpu count, for llmp example
|
|||||||
serial_test = "0.5"
|
serial_test = "0.5"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
time = { version = "0.3.5", default-features = false, features = ["alloc"] }
|
||||||
tuple_list = { version = "0.1.3" }
|
tuple_list = { version = "0.1.3" }
|
||||||
hashbrown = { version = "0.11", features = ["serde", "ahash-compile-time-rng"], default-features=false } # A faster hashmap, nostd compatible
|
hashbrown = { version = "0.11", features = ["serde", "ahash-compile-time-rng"], default-features=false } # A faster hashmap, nostd compatible
|
||||||
num-traits = { version = "0.2", default-features = false }
|
num-traits = { version = "0.2", default-features = false }
|
||||||
|
@ -20,6 +20,7 @@ pub mod shmem;
|
|||||||
pub mod staterestore;
|
pub mod staterestore;
|
||||||
pub mod tuples;
|
pub mod tuples;
|
||||||
|
|
||||||
|
use alloc::string::String;
|
||||||
use core::time;
|
use core::time;
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
use std::time::{SystemTime, UNIX_EPOCH};
|
use std::time::{SystemTime, UNIX_EPOCH};
|
||||||
@ -85,3 +86,9 @@ pub fn current_nanos() -> u64 {
|
|||||||
pub fn current_milliseconds() -> u64 {
|
pub fn current_milliseconds() -> u64 {
|
||||||
current_time().as_millis() as u64
|
current_time().as_millis() as u64
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Format a `Duration` into a HMS string
|
||||||
|
pub fn format_duration_hms(duration: &time::Duration) -> String {
|
||||||
|
let secs = duration.as_secs();
|
||||||
|
format!("{}h-{}m-{}s", (secs / 60) / 60, (secs / 60) % 60, secs % 60)
|
||||||
|
}
|
||||||
|
@ -13,7 +13,7 @@ use hashbrown::HashMap;
|
|||||||
#[cfg(feature = "introspection")]
|
#[cfg(feature = "introspection")]
|
||||||
use alloc::string::ToString;
|
use alloc::string::ToString;
|
||||||
|
|
||||||
use crate::bolts::current_time;
|
use crate::bolts::{current_time, format_duration_hms};
|
||||||
|
|
||||||
const CLIENT_STATS_TIME_WINDOW_SECS: u64 = 5; // 5 seconds
|
const CLIENT_STATS_TIME_WINDOW_SECS: u64 = 5; // 5 seconds
|
||||||
|
|
||||||
@ -269,10 +269,10 @@ where
|
|||||||
|
|
||||||
fn display(&mut self, event_msg: String, sender_id: u32) {
|
fn display(&mut self, event_msg: String, sender_id: u32) {
|
||||||
let fmt = format!(
|
let fmt = format!(
|
||||||
"{}: [{} #{}] clients: {}, corpus: {}, objectives: {}, executions: {}, exec/sec: {}",
|
"[{} #{}] run time: {}, clients: {}, corpus: {}, objectives: {}, executions: {}, exec/sec: {}",
|
||||||
(current_time() - self.start_time).as_millis(),
|
|
||||||
event_msg,
|
event_msg,
|
||||||
sender_id,
|
sender_id,
|
||||||
|
format_duration_hms(&(current_time() - self.start_time)),
|
||||||
self.client_stats().len(),
|
self.client_stats().len(),
|
||||||
self.corpus_size(),
|
self.corpus_size(),
|
||||||
self.objective_size(),
|
self.objective_size(),
|
||||||
|
@ -7,7 +7,7 @@ use core::{time, time::Duration};
|
|||||||
use alloc::string::ToString;
|
use alloc::string::ToString;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
bolts::current_time,
|
bolts::{current_time, format_duration_hms},
|
||||||
monitors::{ClientStats, Monitor},
|
monitors::{ClientStats, Monitor},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -50,8 +50,9 @@ where
|
|||||||
};
|
};
|
||||||
let head = format!("{}{} {}", event_msg, pad, sender);
|
let head = format!("{}{} {}", event_msg, pad, sender);
|
||||||
let global_fmt = format!(
|
let global_fmt = format!(
|
||||||
"[{}] (GLOBAL) clients: {}, corpus: {}, objectives: {}, executions: {}, exec/sec: {}",
|
"[{}] (GLOBAL) run time: {}, clients: {}, corpus: {}, objectives: {}, executions: {}, exec/sec: {}",
|
||||||
head,
|
head,
|
||||||
|
format_duration_hms(&(current_time() - self.start_time)),
|
||||||
self.client_stats().len(),
|
self.client_stats().len(),
|
||||||
self.corpus_size(),
|
self.corpus_size(),
|
||||||
self.objective_size(),
|
self.objective_size(),
|
||||||
|
@ -19,9 +19,6 @@ use crate::{
|
|||||||
Error,
|
Error,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(feature = "introspection")]
|
|
||||||
use crate::monitors::PerfFeature;
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
pub struct SyncFromDiskMetadata {
|
pub struct SyncFromDiskMetadata {
|
||||||
pub last_time: SystemTime,
|
pub last_time: SystemTime,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user