Remove instant dependency in favor of web-time (#767)
This commit is contained in:
@@ -14,6 +14,7 @@ use crate::PhysicsState;
|
||||
use bevy_egui::egui::{Slider, Ui};
|
||||
use bevy_egui::{egui, EguiContexts};
|
||||
use rapier::dynamics::IntegrationParameters;
|
||||
use web_time::Instant;
|
||||
|
||||
pub fn update_ui(
|
||||
ui_context: &mut EguiContexts,
|
||||
@@ -359,94 +360,100 @@ fn scene_infos_ui(ui: &mut Ui, physics: &PhysicsState) {
|
||||
fn profiling_ui(ui: &mut Ui, counters: &Counters) {
|
||||
egui::CollapsingHeader::new(format!(
|
||||
"Total: {:.2}ms - {} fps",
|
||||
counters.step_time(),
|
||||
(1000.0 / counters.step_time()).round()
|
||||
counters.step_time_ms(),
|
||||
(1000.0 / counters.step_time_ms()).round()
|
||||
))
|
||||
.id_source("total")
|
||||
.show(ui, |ui| {
|
||||
egui::CollapsingHeader::new(format!(
|
||||
"Collision detection: {:.2}ms",
|
||||
counters.collision_detection_time()
|
||||
counters.collision_detection_time_ms()
|
||||
))
|
||||
.id_source("collision detection")
|
||||
.show(ui, |ui| {
|
||||
ui.label(format!("Broad-phase: {:.2}ms", counters.broad_phase_time()));
|
||||
ui.label(format!(
|
||||
"Broad-phase: {:.2}ms",
|
||||
counters.broad_phase_time_ms()
|
||||
));
|
||||
ui.label(format!(
|
||||
"Narrow-phase: {:.2}ms",
|
||||
counters.narrow_phase_time()
|
||||
counters.narrow_phase_time_ms()
|
||||
));
|
||||
});
|
||||
egui::CollapsingHeader::new(format!("Solver: {:.2}ms", counters.solver_time()))
|
||||
egui::CollapsingHeader::new(format!("Solver: {:.2}ms", counters.solver_time_ms()))
|
||||
.id_source("solver")
|
||||
.show(ui, |ui| {
|
||||
ui.label(format!(
|
||||
"Velocity assembly: {:.2}ms",
|
||||
counters.solver.velocity_assembly_time.time()
|
||||
counters.solver.velocity_assembly_time.time_ms()
|
||||
));
|
||||
ui.label(format!(
|
||||
"Velocity resolution: {:.2}ms",
|
||||
counters.velocity_resolution_time()
|
||||
counters.velocity_resolution_time_ms()
|
||||
));
|
||||
ui.label(format!(
|
||||
"Velocity integration: {:.2}ms",
|
||||
counters.solver.velocity_update_time.time()
|
||||
counters.solver.velocity_update_time.time_ms()
|
||||
));
|
||||
ui.label(format!(
|
||||
"Writeback: {:.2}ms",
|
||||
counters.solver.velocity_writeback_time.time()
|
||||
counters.solver.velocity_writeback_time.time_ms()
|
||||
));
|
||||
});
|
||||
egui::CollapsingHeader::new(format!("CCD: {:.2}ms", counters.ccd_time()))
|
||||
egui::CollapsingHeader::new(format!("CCD: {:.2}ms", counters.ccd_time_ms()))
|
||||
.id_source("ccd")
|
||||
.show(ui, |ui| {
|
||||
ui.label(format!("# of substeps: {}", counters.ccd.num_substeps));
|
||||
ui.label(format!(
|
||||
"TOI computation: {:.2}ms",
|
||||
counters.ccd.toi_computation_time.time(),
|
||||
counters.ccd.toi_computation_time.time_ms(),
|
||||
));
|
||||
ui.label(format!(
|
||||
"Broad-phase: {:.2}ms",
|
||||
counters.ccd.broad_phase_time.time()
|
||||
counters.ccd.broad_phase_time.time_ms()
|
||||
));
|
||||
ui.label(format!(
|
||||
"Narrow-phase: {:.2}ms",
|
||||
counters.ccd.narrow_phase_time.time(),
|
||||
counters.ccd.narrow_phase_time.time_ms(),
|
||||
));
|
||||
ui.label(format!(
|
||||
"Solver: {:.2}ms",
|
||||
counters.ccd.solver_time.time_ms()
|
||||
));
|
||||
ui.label(format!("Solver: {:.2}ms", counters.ccd.solver_time.time()));
|
||||
});
|
||||
ui.label(format!(
|
||||
"Island computation: {:.2}ms",
|
||||
counters.island_construction_time()
|
||||
counters.island_construction_time_ms()
|
||||
));
|
||||
ui.label(format!(
|
||||
"Query pipeline: {:.2}ms",
|
||||
counters.query_pipeline_update_time()
|
||||
counters.query_pipeline_update_time_ms()
|
||||
));
|
||||
ui.label(format!(
|
||||
"User changes: {:.2}ms",
|
||||
counters.stages.user_changes.time()
|
||||
counters.stages.user_changes.time_ms()
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
fn serialization_string(timestep_id: usize, physics: &PhysicsState) -> String {
|
||||
let t = instant::now();
|
||||
// let t = instant::now();
|
||||
let t = Instant::now();
|
||||
// let t = Instant::now();
|
||||
let bf = bincode::serialize(&physics.broad_phase).unwrap();
|
||||
// println!("bf: {}", instant::now() - t);
|
||||
// let t = instant::now();
|
||||
// println!("bf: {}", Instant::now() - t);
|
||||
// let t = Instant::now();
|
||||
let nf = bincode::serialize(&physics.narrow_phase).unwrap();
|
||||
// println!("nf: {}", instant::now() - t);
|
||||
// let t = instant::now();
|
||||
// println!("nf: {}", Instant::now() - t);
|
||||
// let t = Instant::now();
|
||||
let bs = bincode::serialize(&physics.bodies).unwrap();
|
||||
// println!("bs: {}", instant::now() - t);
|
||||
// let t = instant::now();
|
||||
// println!("bs: {}", Instant::now() - t);
|
||||
// let t = Instant::now();
|
||||
let cs = bincode::serialize(&physics.colliders).unwrap();
|
||||
// println!("cs: {}", instant::now() - t);
|
||||
// let t = instant::now();
|
||||
// println!("cs: {}", Instant::now() - t);
|
||||
// let t = Instant::now();
|
||||
let js = bincode::serialize(&physics.impulse_joints).unwrap();
|
||||
// println!("js: {}", instant::now() - t);
|
||||
let serialization_time = instant::now() - t;
|
||||
// println!("js: {}", Instant::now() - t);
|
||||
let serialization_time = Instant::now() - t;
|
||||
let hash_bf = md5::compute(&bf);
|
||||
let hash_nf = md5::compute(&nf);
|
||||
let hash_bodies = md5::compute(&bs);
|
||||
@@ -460,7 +467,7 @@ Hashes at frame: {}
|
||||
|_ &RigidBodySet [{:.1}KB]: {}
|
||||
|_ Colliders [{:.1}KB]: {}
|
||||
|_ Joints [{:.1}KB]: {}"#,
|
||||
serialization_time,
|
||||
serialization_time.as_secs_f64() * 1000.0,
|
||||
timestep_id,
|
||||
bf.len() as f32 / 1000.0,
|
||||
format!("{:?}", hash_bf).split_at(10).0,
|
||||
|
||||
Reference in New Issue
Block a user