tried to fix stats
This commit is contained in:
parent
3226112a6a
commit
39229e1013
@ -38,6 +38,7 @@ pub enum BrokerEventResult {
|
|||||||
#[derive(Debug, Clone, Default)]
|
#[derive(Debug, Clone, Default)]
|
||||||
pub struct ClientStats {
|
pub struct ClientStats {
|
||||||
// stats (maybe we need a separated struct?)
|
// stats (maybe we need a separated struct?)
|
||||||
|
corpus_size: u64,
|
||||||
executions: u64,
|
executions: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,14 +200,10 @@ impl Stats {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Amount of elements in the corpus (combined for all children)
|
/// Amount of elements in the corpus (combined for all children)
|
||||||
fn corpus_size(&self) -> usize {
|
fn corpus_size(&self) -> u64 {
|
||||||
self.corpus_size
|
self.client_stats()
|
||||||
}
|
.iter()
|
||||||
|
.fold(0u64, |acc, x| acc + x.corpus_size)
|
||||||
/// Incremt the cropus size
|
|
||||||
fn corpus_size_inc(&mut self) -> usize {
|
|
||||||
self.corpus_size += 1;
|
|
||||||
self.corpus_size
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Time this fuzzing run stated
|
/// Time this fuzzing run stated
|
||||||
@ -233,6 +230,17 @@ impl Stats {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The client stats for a specific id, creating new if it doesn't exist
|
||||||
|
fn client_stats_mut_for(&mut self, client_id: u64) -> &mut ClientStats {
|
||||||
|
let client_stat_count = self.client_stats().len();
|
||||||
|
for _ in client_stat_count..(client_id + 1) as usize {
|
||||||
|
self.client_stats_mut().push(ClientStats {
|
||||||
|
..Default::default()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
&mut self.client_stats_mut()[client_id as usize]
|
||||||
|
}
|
||||||
|
|
||||||
/// Broker fun
|
/// Broker fun
|
||||||
#[inline]
|
#[inline]
|
||||||
fn handle_in_broker<I>(&mut self, event: &Event<I>) -> Result<BrokerEventResult, AflError>
|
fn handle_in_broker<I>(&mut self, event: &Event<I>) -> Result<BrokerEventResult, AflError>
|
||||||
@ -241,25 +249,22 @@ impl Stats {
|
|||||||
{
|
{
|
||||||
match event {
|
match event {
|
||||||
Event::LoadInitial {
|
Event::LoadInitial {
|
||||||
sender_id: _,
|
sender_id,
|
||||||
phantom: _,
|
phantom: _,
|
||||||
} => {
|
} => {
|
||||||
self.corpus_size_inc();
|
let client = self.client_stats_mut_for(*sender_id);
|
||||||
|
client.corpus_size += 1;
|
||||||
Ok(BrokerEventResult::Handled)
|
Ok(BrokerEventResult::Handled)
|
||||||
}
|
}
|
||||||
Event::NewTestcase {
|
Event::NewTestcase {
|
||||||
sender_id: _,
|
sender_id,
|
||||||
input: _,
|
input: _,
|
||||||
observers_buf: _,
|
observers_buf: _,
|
||||||
client_config: _,
|
client_config: _,
|
||||||
} => {
|
} => {
|
||||||
self.corpus_size_inc();
|
let client = self.client_stats_mut_for(*sender_id);
|
||||||
println!(
|
client.corpus_size += 1;
|
||||||
"[NEW] corpus: {} execs: {} execs/s: {}",
|
println!("[NEW] client {}: corpus: {}", sender_id, self.corpus_size(),);
|
||||||
self.corpus_size(),
|
|
||||||
self.total_execs(),
|
|
||||||
self.execs_per_sec()
|
|
||||||
);
|
|
||||||
Ok(BrokerEventResult::Forward)
|
Ok(BrokerEventResult::Forward)
|
||||||
}
|
}
|
||||||
Event::UpdateStats {
|
Event::UpdateStats {
|
||||||
@ -269,14 +274,11 @@ impl Stats {
|
|||||||
phantom: _,
|
phantom: _,
|
||||||
} => {
|
} => {
|
||||||
// TODO: The stats buffer should be added on client add.
|
// TODO: The stats buffer should be added on client add.
|
||||||
let client_stat_count = self.client_stats().len();
|
let client = self.client_stats_mut_for(*sender_id);
|
||||||
for _ in client_stat_count..(*sender_id + 1) as usize {
|
client.executions += *executions as u64;
|
||||||
self.client_stats_mut().push(ClientStats { executions: 0 })
|
|
||||||
}
|
|
||||||
let mut stat = &mut self.client_stats_mut()[*sender_id as usize];
|
|
||||||
stat.executions = *executions as u64;
|
|
||||||
println!(
|
println!(
|
||||||
"[UPDATE] corpus: {} execs: {} execs/s: {}",
|
"[UPDATE] from client {}, corpus: {} execs: {} execs/s: {}",
|
||||||
|
sender_id,
|
||||||
self.corpus_size(),
|
self.corpus_size(),
|
||||||
self.total_execs(),
|
self.total_execs(),
|
||||||
self.execs_per_sec()
|
self.execs_per_sec()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user