@@ -93,6 +93,8 @@ impl LogViewerApp {
93
93
}
94
94
95
95
fn show_log_lines ( & mut self , ui : & mut egui:: Ui ) {
96
+ #[ cfg( feature = "profiling" ) ]
97
+ puffin:: profile_scope!( "show_log_lines" ) ;
96
98
let text_height = egui:: TextStyle :: Body
97
99
. resolve ( ui. style ( ) )
98
100
. size
@@ -220,6 +222,8 @@ impl LogViewerApp {
220
222
}
221
223
222
224
fn show_log_details ( & mut self , ui : & mut egui:: Ui ) {
225
+ #[ cfg( feature = "profiling" ) ]
226
+ puffin:: profile_scope!( "show_log_details" ) ;
223
227
let Some ( data) = self . data . as_mut ( ) else {
224
228
ui. label ( "No data" ) ;
225
229
return ;
@@ -315,6 +319,8 @@ impl LogViewerApp {
315
319
self . loading_status = match Data :: try_from ( ( & self . data_display_options , & data[ ..] ) )
316
320
{
317
321
Ok ( mut data) => {
322
+ #[ cfg( feature = "profiling" ) ]
323
+ puffin:: profile_scope!( "swap_data_after_load" ) ;
318
324
if let Some ( old_data) = self . data . as_mut ( ) {
319
325
// Preserve settings across loads of the data
320
326
data. take_config ( old_data, self . data_display_options . common_fields ( ) ) ;
@@ -474,6 +480,9 @@ impl LogViewerApp {
474
480
#[ cfg( not( target_arch = "wasm32" ) ) ]
475
481
/// Attempts to read the contents of the last loaded file and return it in a loading status otherwise returns an error loading status
476
482
fn reload_file ( & self ) -> LoadingStatus {
483
+ #[ cfg( feature = "profiling" ) ]
484
+ puffin:: profile_scope!( "reload_file" ) ;
485
+ // TODO 5: Determine if this should spawn a task to do the load
477
486
let Some ( folder) = self . start_open_path . lock ( ) . unwrap ( ) . clone ( ) else {
478
487
return LoadingStatus :: Failed ( "no staring folder available" . into ( ) ) ;
479
488
} ;
@@ -489,6 +498,9 @@ impl LogViewerApp {
489
498
490
499
#[ cfg( not( target_arch = "wasm32" ) ) ]
491
500
fn load_most_recent_file ( & self ) -> LoadingStatus {
501
+ #[ cfg( feature = "profiling" ) ]
502
+ puffin:: profile_scope!( "load_most_recent_file" ) ;
503
+ // TODO 5: Determine if this should spawn a task to do the load (might be able to reuse the normal load)
492
504
let Some ( folder) = self . start_open_path . lock ( ) . unwrap ( ) . clone ( ) else {
493
505
return LoadingStatus :: Failed ( "unable to find starting folder" . into ( ) ) ;
494
506
} ;
@@ -739,6 +751,8 @@ impl LogViewerApp {
739
751
}
740
752
741
753
fn is_changed_since_last_save ( & mut self ) -> bool {
754
+ #[ cfg( feature = "profiling" ) ]
755
+ puffin:: profile_scope!( "is_changed_since_last_save" ) ;
742
756
let as_ron = match ron:: to_string ( & self ) {
743
757
Ok ( s) => s,
744
758
Err ( err_msg) => {
@@ -804,8 +818,12 @@ fn execute<F: std::future::Future<Output = Box<LoadingStatus>> + 'static>(
804
818
impl eframe:: App for LogViewerApp {
805
819
/// Called by the frame work to save state before shutdown.
806
820
fn save ( & mut self , storage : & mut dyn eframe:: Storage ) {
821
+ #[ cfg( feature = "profiling" ) ]
822
+ puffin:: profile_scope!( "eframe::App::save" ) ;
807
823
if self . is_changed_since_last_save ( ) {
808
824
info ! ( "Saving data" ) ;
825
+ #[ cfg( feature = "profiling" ) ]
826
+ puffin:: profile_scope!( "Saving App State" ) ;
809
827
eframe:: set_value ( storage, eframe:: APP_KEY , self ) ;
810
828
} else {
811
829
debug ! ( "Save skipped, no change detected" ) ;
@@ -814,8 +832,12 @@ impl eframe::App for LogViewerApp {
814
832
815
833
/// Called each time the UI needs repainting, which may be many times per second.
816
834
fn update ( & mut self , ctx : & egui:: Context , _frame : & mut eframe:: Frame ) {
835
+ #[ cfg( feature = "profiling" ) ]
836
+ puffin:: profile_scope!( "update_loop" ) ;
817
837
egui:: TopBottomPanel :: top ( "top_panel" ) . show ( ctx, |ui| {
818
838
// The top panel is often a good place for a menu bar:
839
+ #[ cfg( feature = "profiling" ) ]
840
+ puffin:: profile_scope!( "top_panel" ) ;
819
841
820
842
self . check_global_shortcuts ( ui) ;
821
843
@@ -837,6 +859,8 @@ impl eframe::App for LogViewerApp {
837
859
838
860
egui:: CentralPanel :: default ( ) . show ( ctx, |ui| {
839
861
// The central panel the region left after adding TopPanel's and SidePanel's
862
+ #[ cfg( feature = "profiling" ) ]
863
+ puffin:: profile_scope!( "outer_central_panel" ) ;
840
864
static HEADING : LazyLock < & ' static str > =
841
865
LazyLock :: new ( || format ! ( "Log Viewer {}" , env!( "CARGO_PKG_VERSION" ) ) . leak ( ) ) ;
842
866
ui. heading ( * HEADING ) ;
@@ -857,6 +881,8 @@ impl eframe::App for LogViewerApp {
857
881
. max_height ( max_details_height)
858
882
. min_height ( 60. )
859
883
. show_inside ( ui, |ui| {
884
+ #[ cfg( feature = "profiling" ) ]
885
+ puffin:: profile_scope!( "bottom_panel" ) ;
860
886
ui. vertical_centered ( |ui| {
861
887
ui. heading ( "Details" ) ;
862
888
} ) ;
@@ -871,6 +897,8 @@ impl eframe::App for LogViewerApp {
871
897
} ) ;
872
898
873
899
egui:: CentralPanel :: default ( ) . show_inside ( ui, |ui| {
900
+ #[ cfg( feature = "profiling" ) ]
901
+ puffin:: profile_scope!( "inner_central_panel" ) ;
874
902
egui:: ScrollArea :: horizontal ( )
875
903
. id_salt ( "log lines" )
876
904
. show ( ui, |ui| {
0 commit comments