mirror of
https://github.com/ilya-zlobintsev/LACT.git
synced 2025-02-25 18:55:26 -06:00
chore: update bench
This commit is contained in:
parent
0894f9ae9d
commit
5bd588738f
@ -26,6 +26,7 @@ chrono = "0.4.31"
|
||||
indexmap = { version = "2.5.0", features = ["serde"] }
|
||||
pretty_assertions = "1.4.0"
|
||||
divan = "0.1"
|
||||
gtk = { version = "0.9", package = "gtk4" }
|
||||
|
||||
[profile.release]
|
||||
strip = "symbols"
|
||||
|
@ -20,8 +20,8 @@ tracing = { workspace = true }
|
||||
anyhow = { workspace = true }
|
||||
tracing-subscriber = { workspace = true }
|
||||
chrono = { workspace = true }
|
||||
gtk = { workspace = true, features = ["v4_6", "blueprint"] }
|
||||
|
||||
gtk = { version = "0.9", package = "gtk4", features = ["v4_6", "blueprint"] }
|
||||
adw = { package = "libadwaita", version = "0.7.1", features = [
|
||||
"v1_4",
|
||||
], optional = true }
|
||||
|
@ -193,3 +193,58 @@ impl PlotData {
|
||||
self.line_series.is_empty() && self.secondary_line_series.is_empty()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "bench")]
|
||||
mod benches {
|
||||
use crate::app::graphs_window::plot::{
|
||||
render_thread::{process_request, RenderRequest},
|
||||
PlotData,
|
||||
};
|
||||
use chrono::{NaiveDate, NaiveDateTime, NaiveTime};
|
||||
use divan::{counter::ItemsCount, Bencher};
|
||||
use std::sync::Mutex;
|
||||
|
||||
#[divan::bench]
|
||||
fn render_plot(bencher: Bencher) {
|
||||
let last_texture = &Mutex::new(None);
|
||||
|
||||
bencher
|
||||
.with_inputs(sample_plot_data)
|
||||
.input_counter(|_| ItemsCount::new(1usize))
|
||||
.bench_values(|data| {
|
||||
let request = RenderRequest {
|
||||
title: "bench render".into(),
|
||||
value_suffix: "%".into(),
|
||||
secondary_value_suffix: "".into(),
|
||||
y_label_area_relative_size: 1.0,
|
||||
secondary_y_label_relative_area_size: 1.0,
|
||||
data,
|
||||
width: 1920,
|
||||
height: 1080,
|
||||
supersample_factor: 4,
|
||||
time_period_seconds: 60,
|
||||
};
|
||||
|
||||
process_request(request, last_texture)
|
||||
});
|
||||
}
|
||||
|
||||
fn sample_plot_data() -> PlotData {
|
||||
let mut data = PlotData::default();
|
||||
|
||||
// Simulate 1 minute plot with 4 values per second
|
||||
for sec in 0..60 {
|
||||
for milli in [0, 250, 500, 750] {
|
||||
let datetime = NaiveDateTime::new(
|
||||
NaiveDate::from_ymd_opt(2025, 1, 1).unwrap(),
|
||||
NaiveTime::from_hms_milli_opt(0, 0, sec, milli).unwrap(),
|
||||
);
|
||||
|
||||
data.push_line_series_with_time("GPU", 100.0, datetime);
|
||||
data.push_secondary_line_series_with_time("GPU Secondary", 10.0, datetime);
|
||||
}
|
||||
}
|
||||
|
||||
data
|
||||
}
|
||||
}
|
||||
|
@ -130,7 +130,10 @@ impl RenderThread {
|
||||
}
|
||||
}
|
||||
|
||||
fn process_request(render_request: RenderRequest, last_texture: &Mutex<Option<MemoryTexture>>) {
|
||||
pub(super) fn process_request(
|
||||
render_request: RenderRequest,
|
||||
last_texture: &Mutex<Option<MemoryTexture>>,
|
||||
) {
|
||||
// Create a new ImageSurface for Cairo rendering.
|
||||
let mut surface = ImageSurface::create(
|
||||
cairo::Format::ARgb32,
|
||||
@ -393,56 +396,3 @@ impl RenderRequest {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "bench")]
|
||||
mod benches {
|
||||
use super::{process_request, RenderRequest};
|
||||
use crate::app::graphs_window::plot::PlotData;
|
||||
use chrono::{NaiveDate, NaiveDateTime, NaiveTime};
|
||||
use divan::{counter::ItemsCount, Bencher};
|
||||
use std::sync::Mutex;
|
||||
|
||||
#[divan::bench]
|
||||
fn render_plot(bencher: Bencher) {
|
||||
let last_texture = &Mutex::new(None);
|
||||
|
||||
bencher
|
||||
.with_inputs(sample_plot_data)
|
||||
.input_counter(|_| ItemsCount::new(1usize))
|
||||
.bench_values(|data| {
|
||||
let request = RenderRequest {
|
||||
title: "bench render".into(),
|
||||
value_suffix: "%".into(),
|
||||
secondary_value_suffix: "".into(),
|
||||
y_label_area_relative_size: 1.0,
|
||||
secondary_y_label_relative_area_size: 1.0,
|
||||
data,
|
||||
width: 1920,
|
||||
height: 1080,
|
||||
supersample_factor: 4,
|
||||
time_period_seconds: 60,
|
||||
};
|
||||
|
||||
process_request(request, last_texture)
|
||||
});
|
||||
}
|
||||
|
||||
fn sample_plot_data() -> PlotData {
|
||||
let mut data = PlotData::default();
|
||||
|
||||
// Simulate 1 minute plot with 4 values per second
|
||||
for sec in 0..60 {
|
||||
for milli in [0, 250, 500, 750] {
|
||||
let datetime = NaiveDateTime::new(
|
||||
NaiveDate::from_ymd_opt(2025, 1, 1).unwrap(),
|
||||
NaiveTime::from_hms_milli_opt(0, 0, sec, milli).unwrap(),
|
||||
);
|
||||
|
||||
data.push_line_series_with_time("GPU", 100.0, datetime);
|
||||
data.push_secondary_line_series_with_time("GPU Secondary", 10.0, datetime);
|
||||
}
|
||||
}
|
||||
|
||||
data
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user