11//! Adds diagnostic logging and a cursor for debugging.
22
33use bevy:: {
4- diagnostic:: { Diagnostic , DiagnosticId , Diagnostics , RegisterDiagnostic } ,
4+ diagnostic:: { Diagnostic , DiagnosticPath , Diagnostics , RegisterDiagnostic } ,
55 prelude:: * ,
66} ;
77
@@ -12,24 +12,18 @@ impl Plugin for DiagnosticsPlugin {
1212 fn build ( & self , app : & mut App ) {
1313 app. add_systems ( Update , Self :: diagnostic_system) ;
1414
15- app. register_diagnostic (
16- Diagnostic :: new ( Self :: FRAMEPACE_FRAMETIME , "framepace::frametime" , 128 )
17- . with_suffix ( "ms" ) ,
18- ) ;
19- app. register_diagnostic (
20- Diagnostic :: new ( Self :: FRAMEPACE_OVERSLEEP , "framepace::oversleep" , 128 )
21- . with_suffix ( "µs" ) ,
22- ) ;
15+ app. register_diagnostic ( Diagnostic :: new ( Self :: FRAMEPACE_FRAMETIME ) . with_suffix ( "ms" ) ) ;
16+ app. register_diagnostic ( Diagnostic :: new ( Self :: FRAMEPACE_OVERSLEEP ) . with_suffix ( "µs" ) ) ;
2317 }
2418}
2519
2620impl DiagnosticsPlugin {
27- /// [`DiagnosticId `] for the frametime
28- pub const FRAMEPACE_FRAMETIME : DiagnosticId =
29- DiagnosticId :: from_u128 ( 8021378406439507683279787892187089153 ) ;
30- /// [`DiagnosticId `] for failures to meet frame time target
31- pub const FRAMEPACE_OVERSLEEP : DiagnosticId =
32- DiagnosticId :: from_u128 ( 978023490268634078905367093342937 ) ;
21+ /// [`DiagnosticPath `] for the frametime
22+ pub const FRAMEPACE_FRAMETIME : DiagnosticPath =
23+ DiagnosticPath :: const_new ( "framepace/frametime" ) ;
24+ /// [`DiagnosticPath `] for failures to meet frame time target
25+ pub const FRAMEPACE_OVERSLEEP : DiagnosticPath =
26+ DiagnosticPath :: const_new ( "framepace/oversleep" ) ;
3327
3428 /// Updates diagnostic data from measurements
3529 pub fn diagnostic_system (
@@ -44,7 +38,7 @@ impl DiagnosticsPlugin {
4438 let frametime_millis = stats. frametime . try_lock ( ) . unwrap ( ) . as_secs_f64 ( ) * 1_000_f64 ;
4539 let error_micros = stats. oversleep . try_lock ( ) . unwrap ( ) . as_secs_f64 ( ) * 1_000_000_f64 ;
4640
47- diagnostics. add_measurement ( Self :: FRAMEPACE_FRAMETIME , || frametime_millis) ;
48- diagnostics. add_measurement ( Self :: FRAMEPACE_OVERSLEEP , || error_micros) ;
41+ diagnostics. add_measurement ( & Self :: FRAMEPACE_FRAMETIME , || frametime_millis) ;
42+ diagnostics. add_measurement ( & Self :: FRAMEPACE_OVERSLEEP , || error_micros) ;
4943 }
5044}
0 commit comments