fix a bit exec sec in stats
This commit is contained in:
parent
27cc1d8af6
commit
177135d330
@ -101,13 +101,17 @@ where
|
||||
corpus_size: usize,
|
||||
/// The client config for this observers/testcase combination
|
||||
client_config: String,
|
||||
/// The time of generation of the event
|
||||
time: Duration,
|
||||
/// The executions of this client
|
||||
executions: usize,
|
||||
},
|
||||
/// New stats.
|
||||
UpdateStats {
|
||||
/// The time of generation of the event
|
||||
time: Duration,
|
||||
/// The executions of this client
|
||||
executions: usize,
|
||||
/// The execs per sec for this client
|
||||
execs_over_sec: u64,
|
||||
phantom: PhantomData<I>,
|
||||
},
|
||||
/// A crash was found
|
||||
@ -146,10 +150,12 @@ where
|
||||
client_config: _,
|
||||
corpus_size: _,
|
||||
observers_buf: _,
|
||||
time: _,
|
||||
executions: _,
|
||||
} => "New Testcase",
|
||||
Event::UpdateStats {
|
||||
time: _,
|
||||
executions: _,
|
||||
execs_over_sec: _,
|
||||
phantom: _,
|
||||
} => "Stats",
|
||||
Event::Crash { input: _ } => "Crash",
|
||||
@ -332,18 +338,21 @@ where
|
||||
client_config: _,
|
||||
corpus_size,
|
||||
observers_buf: _,
|
||||
time,
|
||||
executions,
|
||||
} => {
|
||||
stats.client_stats_mut()[0].corpus_size = *corpus_size as u64;
|
||||
stats.client_stats_mut()[0].update_corpus_size(*corpus_size as u64);
|
||||
stats.client_stats_mut()[0].update_executions(*executions as u64, *time);
|
||||
stats.display(event.name().to_string());
|
||||
Ok(BrokerEventResult::Handled)
|
||||
}
|
||||
Event::UpdateStats {
|
||||
time,
|
||||
executions,
|
||||
execs_over_sec: _,
|
||||
phantom: _,
|
||||
} => {
|
||||
// TODO: The stats buffer should be added on client add.
|
||||
stats.client_stats_mut()[0].executions = *executions as u64;
|
||||
stats.client_stats_mut()[0].update_executions(*executions as u64, *time);
|
||||
stats.display(event.name().to_string());
|
||||
Ok(BrokerEventResult::Handled)
|
||||
}
|
||||
@ -568,20 +577,23 @@ where
|
||||
client_config: _,
|
||||
corpus_size,
|
||||
observers_buf: _,
|
||||
time,
|
||||
executions
|
||||
} => {
|
||||
let client = stats.client_stats_mut_for(sender_id);
|
||||
client.corpus_size = *corpus_size as u64;
|
||||
client.update_corpus_size(*corpus_size as u64);
|
||||
client.update_executions(*executions as u64, *time);
|
||||
stats.display(event.name().to_string() + " #" + &sender_id.to_string());
|
||||
Ok(BrokerEventResult::Handled)
|
||||
}
|
||||
Event::UpdateStats {
|
||||
time,
|
||||
executions,
|
||||
execs_over_sec: _,
|
||||
phantom: _,
|
||||
} => {
|
||||
// TODO: The stats buffer should be added on client add.
|
||||
let client = stats.client_stats_mut_for(sender_id);
|
||||
client.executions = *executions as u64;
|
||||
client.update_executions(*executions as u64, *time);
|
||||
stats.display(event.name().to_string() + " #" + &sender_id.to_string());
|
||||
Ok(BrokerEventResult::Handled)
|
||||
}
|
||||
@ -626,6 +638,8 @@ where
|
||||
client_config: _,
|
||||
corpus_size: _,
|
||||
observers_buf,
|
||||
time: _,
|
||||
executions: _
|
||||
} => {
|
||||
// TODO: here u should match client_config, if equal to the current one do not re-execute
|
||||
// we need to pass engine to process() too, TODO
|
||||
@ -946,6 +960,7 @@ mod tests {
|
||||
use crate::inputs::bytes::BytesInput;
|
||||
use crate::observers::ObserversTuple;
|
||||
use crate::observers::StdMapObserver;
|
||||
use crate::utils::current_time;
|
||||
|
||||
static mut MAP: [u32; 4] = [0; 4];
|
||||
|
||||
@ -961,6 +976,8 @@ mod tests {
|
||||
observers_buf,
|
||||
corpus_size: 123,
|
||||
client_config: "conf".into(),
|
||||
time: current_time(),
|
||||
executions: 0
|
||||
};
|
||||
|
||||
let serialized = postcard::to_allocvec(&e).unwrap();
|
||||
@ -972,6 +989,8 @@ mod tests {
|
||||
observers_buf,
|
||||
corpus_size: _,
|
||||
client_config: _,
|
||||
time: _,
|
||||
executions: _
|
||||
} => {
|
||||
let o = map.deserialize(&observers_buf).unwrap();
|
||||
let test_observer = o.match_name_type::<StdMapObserver<u32>>("test").unwrap();
|
||||
|
@ -27,13 +27,19 @@ impl ClientStats {
|
||||
/// We got a new information about executions for this client, insert them.
|
||||
pub fn update_executions(&mut self, executions: u64, cur_time: time::Duration) {
|
||||
self.executions = executions;
|
||||
if (cur_time - self.last_window_time).as_secs() > CLIENT_STATS_TIME_WINDOW_SECS {
|
||||
let diff = cur_time.checked_sub(self.last_window_time).map_or(0, |d| d.as_secs());
|
||||
if diff > CLIENT_STATS_TIME_WINDOW_SECS {
|
||||
self.last_execs_per_sec = self.execs_per_sec(cur_time);
|
||||
self.last_window_time = cur_time;
|
||||
self.last_window_executions = executions;
|
||||
}
|
||||
}
|
||||
|
||||
/// We got a new information about corpus size for this client, insert them.
|
||||
pub fn update_corpus_size(&mut self, corpus_size: u64) {
|
||||
self.corpus_size = corpus_size;
|
||||
}
|
||||
|
||||
/// Get the calculated executions per second for this client
|
||||
pub fn execs_per_sec(&self, cur_time: time::Duration) -> u64 {
|
||||
if self.executions == 0 {
|
||||
|
@ -32,7 +32,7 @@ use inputs::Input;
|
||||
use observers::ObserversTuple;
|
||||
use stages::StagesTuple;
|
||||
use state::{HasCorpus, State};
|
||||
use utils::{current_milliseconds, Rand};
|
||||
use utils::{current_milliseconds, current_time, Rand};
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
use std::{env::VarError, io, num::ParseIntError, string::FromUtf8Error};
|
||||
@ -86,7 +86,7 @@ where
|
||||
state,
|
||||
Event::UpdateStats {
|
||||
executions: state.executions(),
|
||||
execs_over_sec: state.executions_over_seconds(),
|
||||
time: current_time(),
|
||||
phantom: PhantomData,
|
||||
},
|
||||
)?
|
||||
|
@ -307,9 +307,7 @@ where
|
||||
scheduled.add_mutation(mutation_tokeninsert);
|
||||
scheduled.add_mutation(mutation_tokenreplace);
|
||||
*/
|
||||
|
||||
// TODO: custom dictionary (redqueen etc.)
|
||||
|
||||
|
||||
scheduled.add_mutation(mutation_splice);
|
||||
|
||||
HavocBytesMutator {
|
||||
|
@ -86,6 +86,8 @@ where
|
||||
observers_buf,
|
||||
corpus_size: state.corpus().count() + 1,
|
||||
client_config: "TODO".into(),
|
||||
time: crate::utils::current_time(),
|
||||
executions: state.executions(),
|
||||
},
|
||||
)?;
|
||||
state.add_if_interesting(input_mut, fitness)?;
|
||||
|
@ -68,6 +68,7 @@ where
|
||||
executions: usize,
|
||||
/// The corpus
|
||||
corpus: C,
|
||||
// TODO use Duration
|
||||
/// At what time the fuzzing started
|
||||
start_time: u64,
|
||||
/// Metadata stored for this state by one of the components
|
||||
@ -218,20 +219,6 @@ where
|
||||
pub fn set_start_time(&mut self, ms: u64) {
|
||||
self.start_time = ms
|
||||
}
|
||||
// TODO as this is done in the event manager, we can remove it
|
||||
#[inline]
|
||||
pub fn executions_over_seconds(&self) -> u64 {
|
||||
let elapsed = current_milliseconds() - self.start_time();
|
||||
if elapsed == 0 {
|
||||
return 0;
|
||||
}
|
||||
let elapsed = elapsed / 1000;
|
||||
if elapsed == 0 {
|
||||
0
|
||||
} else {
|
||||
(self.executions() as u64) / elapsed
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns vector of feebacks
|
||||
#[inline]
|
||||
|
Loading…
x
Reference in New Issue
Block a user