status info

main
Antonio De Lucreziis 6 months ago
parent b54ac113dd
commit 4f40617568

@ -1,9 +1,9 @@
use std::{collections::HashMap, env, ops::AddAssign, time::Instant};
use asd::{gfa::Entry, parser};
use macroquad::{prelude::*, rand};
use macroquad::{prelude::*, rand, ui::root_ui};
use nalgebra::{Point2, SVector};
use petgraph::{algo::dijkstra, stable_graph::StableGraph};
use petgraph::{algo::dijkstra, graph::NodeIndex, stable_graph::StableGraph};
use rayon::prelude::*;
@ -24,6 +24,37 @@ async fn main() {
loop {
// Update
let start_update = Instant::now();
update(&mut graph, &desired_distance_matrix);
let update_elapsed = start_update.elapsed();
// Render
let start_render = Instant::now();
clear_background(WHITE);
draw_graph(&graph);
let render_elapsed = start_render.elapsed();
root_ui().label(
None,
format!("update: {:?}, render: {:?}", update_elapsed, render_elapsed).as_str(),
);
// println!("update: {:?}, render: {:?}", update_elapsed, render_elapsed);
next_frame().await
}
}
fn update(
graph: &mut StableGraph<(String, Point2<f32>), ()>,
desired_distance_matrix: &HashMap<NodeIndex, HashMap<NodeIndex, f32>>,
) {
for _ in 1..2 {
let forces = graph
.node_indices()
@ -89,21 +120,6 @@ async fn main() {
pos.add_assign(force);
});
}
// Render
let now = Instant::now();
clear_background(WHITE);
draw_graph(&graph);
let elapsed = now.elapsed();
println!("frame: {:?}", elapsed);
next_frame().await
}
}
fn load_graph() -> StableGraph<(String, Point2<f32>), ()> {

Loading…
Cancel
Save