timing
This commit is contained in:
parent
474ccb949f
commit
0d074794de
1
TODO.md
1
TODO.md
@ -1,6 +1,5 @@
|
|||||||
## TODO:
|
## TODO:
|
||||||
1. Port to [egui](https://github.com/emilk/egui)
|
1. Port to [egui](https://github.com/emilk/egui)
|
||||||
- Proper support for dynamic chart display size.
|
- Proper support for dynamic chart display size.
|
||||||
- Add time took to generate
|
|
||||||
2. Multiple functions in one graph.
|
2. Multiple functions in one graph.
|
||||||
3. Non `y=` functions.
|
3. Non `y=` functions.
|
||||||
@ -6,7 +6,7 @@ use egui::{
|
|||||||
plot::{Line, Plot, Value, Values},
|
plot::{Line, Plot, Value, Values},
|
||||||
};
|
};
|
||||||
use egui::{Color32};
|
use egui::{Color32};
|
||||||
|
use std::time::Instant;
|
||||||
|
|
||||||
pub struct MathApp {
|
pub struct MathApp {
|
||||||
func_str: String,
|
func_str: String,
|
||||||
@ -50,6 +50,7 @@ impl epi::App for MathApp {
|
|||||||
resolution: _,
|
resolution: _,
|
||||||
chart_manager,
|
chart_manager,
|
||||||
} = self;
|
} = self;
|
||||||
|
let start = Instant::now();
|
||||||
|
|
||||||
let min_x_total: f32 = -1000.0;
|
let min_x_total: f32 = -1000.0;
|
||||||
let max_x_total: f32 = 1000.0;
|
let max_x_total: f32 = 1000.0;
|
||||||
@ -116,17 +117,17 @@ impl epi::App for MathApp {
|
|||||||
.map(|(x, y)| Bar::new(*x, *y))
|
.map(|(x, y)| Bar::new(*x, *y))
|
||||||
.collect();
|
.collect();
|
||||||
let barchart = BarChart::new(bars).color(Color32::BLUE);
|
let barchart = BarChart::new(bars).color(Color32::BLUE);
|
||||||
|
|
||||||
ui.label(format!("Area: {}", digits_precision(area, 8)));
|
|
||||||
Plot::new("plot")
|
Plot::new("plot")
|
||||||
.view_aspect(1.0)
|
.view_aspect(1.0)
|
||||||
.include_y(0)
|
.include_y(0)
|
||||||
.show(ui, |plot_ui| {
|
.show(ui, |plot_ui| {
|
||||||
plot_ui.line(curve);
|
plot_ui.line(curve);
|
||||||
if self.num_interval > 0 {
|
plot_ui.bar_chart(barchart);
|
||||||
plot_ui.bar_chart(barchart);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let duration = start.elapsed();
|
||||||
|
|
||||||
|
ui.label(format!("Area: {} Took: {:?}", digits_precision(area, 8), duration));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user