* incroyable

* lolg
This commit is contained in:
Dongjia "toka" Zhang 2025-04-08 22:20:17 +02:00 committed by GitHub
parent fb8939eefc
commit 8683c68e59
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 29 additions and 43 deletions

View File

@ -187,7 +187,7 @@ impl ClientStatsManager {
let mut total_process_timing = ProcessTiming::new();
total_process_timing.exec_speed = execs_per_sec_pretty;
total_process_timing.total_execs = total_execs;
if self.client_stats().len() > 1 {
if !self.client_stats().is_empty() {
let mut new_path_time = Duration::default();
let mut new_objectives_time = Duration::default();
for (_, stat) in self
@ -199,10 +199,10 @@ impl ClientStatsManager {
new_objectives_time = stat.last_objective_time().max(new_objectives_time);
}
if new_path_time > self.start_time() {
total_process_timing.last_new_entry = new_path_time - self.start_time();
total_process_timing.last_new_entry = current_time() - new_path_time;
}
if new_objectives_time > self.start_time() {
total_process_timing.last_saved_solution = new_objectives_time - self.start_time();
total_process_timing.last_saved_solution = current_time() - new_objectives_time;
}
}
total_process_timing

View File

@ -329,13 +329,13 @@ impl ClientStats {
pub fn process_timing(&mut self) -> ProcessTiming {
let client_start_time = self.start_time();
let last_new_entry = if self.last_corpus_time() > self.start_time() {
self.last_corpus_time() - self.start_time()
current_time() - self.last_corpus_time()
} else {
Duration::default()
};
let last_saved_solution = if self.last_objective_time() > self.start_time() {
self.last_objective_time() - self.start_time()
current_time() - self.last_objective_time()
} else {
Duration::default()
};

View File

@ -26,7 +26,7 @@ pub struct TuiUi {
version: String,
enhanced_graphics: bool,
show_logs: bool,
clients_idx: usize,
client_idx: usize,
clients: usize,
charts_tab_idx: usize,
graph_data: Vec<(f64, f64)>,
@ -48,7 +48,7 @@ impl TuiUi {
version,
enhanced_graphics,
show_logs: true,
clients_idx: 1,
client_idx: 0,
..TuiUi::default()
}
}
@ -67,29 +67,15 @@ impl TuiUi {
}
}
//pub fn on_up(&mut self) {}
//pub fn on_down(&mut self) {}
pub fn on_right(&mut self) {
if self.clients != 0 {
// clients_idx never 0
if self.clients - 1 != 0 {
// except for when it is ;)
self.clients_idx = 1 + self.clients_idx % (self.clients - 1);
}
if self.clients > 0 && self.client_idx < self.clients - 1 {
self.client_idx += 1;
}
}
pub fn on_left(&mut self) {
if self.clients != 0 {
// clients_idx never 0
if self.clients_idx == 1 {
self.clients_idx = self.clients - 1;
} else if self.clients - 1 != 0 {
// don't wanna be dividing by 0
self.clients_idx = 1 + (self.clients_idx - 2) % (self.clients - 1);
}
if self.client_idx > 0 {
self.client_idx -= 1;
}
}
@ -248,7 +234,7 @@ impl TuiUi {
fn draw_client_ui(&mut self, f: &mut Frame, app: &Arc<RwLock<TuiContext>>, area: Rect) {
let client_block = Block::default()
.title(Span::styled(
format!("client #{} (l/r arrows to switch)", self.clients_idx),
format!("client #{} (←/→ arrows to switch)", self.client_idx),
Style::default()
.fg(Color::LightCyan)
.add_modifier(Modifier::BOLD),
@ -431,16 +417,16 @@ impl TuiUi {
let empty_geometry: ItemGeometry = ItemGeometry::new();
let item_geometry: &ItemGeometry = if is_overall {
&tui_context.total_item_geometry
} else if self.clients < 2 {
} else if self.clients == 0 {
&empty_geometry
} else {
let clients = &tui_context.clients;
let client = clients.get(&self.clients_idx);
let client = clients.get(&self.client_idx);
let client = client.as_ref();
if let Some(client) = client {
&client.item_geometry
} else {
log::warn!("Client {} was `None`. Race condition?", &self.clients_idx);
log::warn!("Client {} was `None`. Race condition?", &self.client_idx);
&empty_geometry
}
};
@ -508,11 +494,11 @@ impl TuiUi {
let empty_timing: ProcessTiming = ProcessTiming::new();
let tup: (Duration, &ProcessTiming) = if is_overall {
(tui_context.start_time, &tui_context.total_process_timing)
} else if self.clients < 2 {
} else if self.clients == 0 {
(current_time(), &empty_timing)
} else {
let clients = &tui_context.clients;
let client = clients.get(&self.clients_idx);
let client = clients.get(&self.client_idx);
let client = client.as_ref();
if let Some(client) = client {
(
@ -520,29 +506,29 @@ impl TuiUi {
&client.process_timing,
)
} else {
log::warn!("Client {} was `None`. Race condition?", &self.clients_idx);
log::warn!("Client {} was `None`. Race condition?", &self.client_idx);
(current_time(), &empty_timing)
}
};
let items = vec![
Row::new(vec![
Cell::from(Span::raw("run time")),
Cell::from(Span::raw("global run time")),
Cell::from(Span::raw(format_duration_hms(&(current_time() - tup.0)))),
]),
Row::new(vec![
Cell::from(Span::raw("exec speed")),
Cell::from(Span::raw("global exec speed")),
Cell::from(Span::raw(&tup.1.exec_speed)),
]),
Row::new(vec![
Cell::from(Span::raw("total execs")),
Cell::from(Span::raw("global total execs")),
Cell::from(Span::raw(format_big_number(tup.1.total_execs))),
]),
Row::new(vec![
Cell::from(Span::raw("last new entry")),
Cell::from(Span::raw("global last new entry")),
Cell::from(Span::raw(format_duration_hms(&(tup.1.last_new_entry)))),
]),
Row::new(vec![
Cell::from(Span::raw("last solution")),
Cell::from(Span::raw("global last solution")),
Cell::from(Span::raw(format_duration_hms(&(tup.1.last_saved_solution)))),
]),
];
@ -642,7 +628,7 @@ impl TuiUi {
Cell::from(Span::raw(format!(
"{}",
app.clients
.get(&self.clients_idx)
.get(&self.client_idx)
.map_or(0, |x| x.cycles_done)
))),
]),
@ -651,7 +637,7 @@ impl TuiUi {
Cell::from(Span::raw(format!(
"{}",
app.clients
.get(&self.clients_idx)
.get(&self.client_idx)
.map_or(0, |x| x.objectives)
))),
]),
@ -686,14 +672,14 @@ impl TuiUi {
Row::new(vec![
Cell::from(Span::raw("corpus count")),
Cell::from(Span::raw(format_big_number(
app.clients.get(&self.clients_idx).map_or(0, |x| x.corpus),
app.clients.get(&self.client_idx).map_or(0, |x| x.corpus),
))),
]),
Row::new(vec![
Cell::from(Span::raw("total execs")),
Cell::from(Span::raw(format_big_number(
app.clients
.get(&self.clients_idx)
.get(&self.client_idx)
.map_or(0, |x| x.executions),
))),
]),
@ -701,7 +687,7 @@ impl TuiUi {
Cell::from(Span::raw("map density")),
Cell::from(Span::raw(
app.clients
.get(&self.clients_idx)
.get(&self.client_idx)
.map_or("0%".to_string(), |x| x.map_density.to_string()),
)),
]),
@ -734,7 +720,7 @@ impl TuiUi {
let mut items = vec![];
{
let ctx = app.read().unwrap();
if let Some(client) = ctx.introspection.get(&self.clients_idx) {
if let Some(client) = ctx.introspection.get(&self.client_idx) {
items.push(Row::new(vec![
Cell::from(Span::raw("scheduler")),
Cell::from(Span::raw(format!("{:.2}%", client.scheduler * 100.0))),