fix: Benchmarks submenu, fix Ui and big optimization for table.

fix: do not render all the rows, only the ones visibles.
This commit is contained in:
Louis-Marie Baer 2024-03-22 00:01:44 +01:00
parent 7797b5e81d
commit 46486b5364

View file

@ -19,7 +19,7 @@ impl Status {
xmrig_api: &Arc<Mutex<PubXmrigApi>>, xmrig_api: &Arc<Mutex<PubXmrigApi>>,
) { ) {
debug!("Status Tab | Rendering [Benchmarks]"); debug!("Status Tab | Rendering [Benchmarks]");
let text = size.x / 20.0; let text = size.y / 20.0;
let double = text * 2.0; let double = text * 2.0;
let log = size.y / 3.0; let log = size.y / 3.0;
@ -28,7 +28,7 @@ impl Status {
// [0], The user's CPU (most likely). // [0], The user's CPU (most likely).
let cpu = &benchmarks[0]; let cpu = &benchmarks[0];
ui.horizontal(|ui| { ui.horizontal(|ui| {
let width = (size.x / 2.0) - (SPACE * 1.666); let width = (width / 2.0) - (SPACE * 1.666);
let min_height = log; let min_height = log;
ui.group(|ui| { ui.group(|ui| {
ui.vertical(|ui| { ui.vertical(|ui| {
@ -145,7 +145,7 @@ impl Status {
.max_width(width) .max_width(width)
.max_height(height) .max_height(height)
.auto_shrink([false; 2]) .auto_shrink([false; 2])
.show_viewport(ui, |ui, _| { .show_rows(ui, text, benchmarks.len(), |ui, row_range| {
let width = width / 20.0; let width = width / 20.0;
let (cpu, bar, high, average, low, rank, bench) = ( let (cpu, bar, high, average, low, rank, bench) = (
width * 10.0, width * 10.0,
@ -180,8 +180,8 @@ impl Status {
.on_hover_text(STATUS_SUBMENU_OTHER_BENCHMARKS); .on_hover_text(STATUS_SUBMENU_OTHER_BENCHMARKS);
}); });
}); });
for row in row_range {
for benchmark in benchmarks[1..].iter() { let benchmark = &benchmarks[row];
ui.group(|ui| { ui.group(|ui| {
ui.horizontal(|ui| { ui.horizontal(|ui| {
ui.add_sized([cpu, text], Label::new(benchmark.cpu.as_str())); ui.add_sized([cpu, text], Label::new(benchmark.cpu.as_str()));
@ -191,20 +191,25 @@ impl Status {
ui.separator(); ui.separator();
ui.add_sized( ui.add_sized(
[high, text], [high, text],
Label::new(format!("{} H/s", Float::from_0(benchmark.high.into()))), Label::new(
[Float::from_0(benchmark.high.into()).as_str(), " H/s"]
.concat(),
),
); );
ui.separator(); ui.separator();
ui.add_sized( ui.add_sized(
[average, text], [average, text],
Label::new(format!( Label::new(
"{} H/s", [Float::from_0(benchmark.average.into()).as_str(), " H/s"]
Float::from_0(benchmark.average.into()) .concat(),
)), ),
); );
ui.separator(); ui.separator();
ui.add_sized( ui.add_sized(
[low, text], [low, text],
Label::new(format!("{} H/s", Float::from_0(benchmark.low.into()))), Label::new(
[Float::from_0(benchmark.low.into()).as_str(), " H/s"].concat(),
),
); );
ui.separator(); ui.separator();
ui.add_sized( ui.add_sized(