@@ -93,6 +93,8 @@ impl LogViewerApp {
9393 }
9494
9595 fn show_log_lines ( & mut self , ui : & mut egui:: Ui ) {
96+ #[ cfg( feature = "profiling" ) ]
97+ puffin:: profile_scope!( "show_log_lines" ) ;
9698 let text_height = egui:: TextStyle :: Body
9799 . resolve ( ui. style ( ) )
98100 . size
@@ -220,6 +222,8 @@ impl LogViewerApp {
220222 }
221223
222224 fn show_log_details ( & mut self , ui : & mut egui:: Ui ) {
225+ #[ cfg( feature = "profiling" ) ]
226+ puffin:: profile_scope!( "show_log_details" ) ;
223227 let Some ( data) = self . data . as_mut ( ) else {
224228 ui. label ( "No data" ) ;
225229 return ;
@@ -315,6 +319,8 @@ impl LogViewerApp {
315319 self . loading_status = match Data :: try_from ( ( & self . data_display_options , & data[ ..] ) )
316320 {
317321 Ok ( mut data) => {
322+ #[ cfg( feature = "profiling" ) ]
323+ puffin:: profile_scope!( "swap_data_after_load" ) ;
318324 if let Some ( old_data) = self . data . as_mut ( ) {
319325 // Preserve settings across loads of the data
320326 data. take_config ( old_data, self . data_display_options . common_fields ( ) ) ;
@@ -474,6 +480,9 @@ impl LogViewerApp {
474480 #[ cfg( not( target_arch = "wasm32" ) ) ]
475481 /// Attempts to read the contents of the last loaded file and return it in a loading status otherwise returns an error loading status
476482 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
477486 let Some ( folder) = self . start_open_path . lock ( ) . unwrap ( ) . clone ( ) else {
478487 return LoadingStatus :: Failed ( "no staring folder available" . into ( ) ) ;
479488 } ;
@@ -489,6 +498,9 @@ impl LogViewerApp {
489498
490499 #[ cfg( not( target_arch = "wasm32" ) ) ]
491500 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)
492504 let Some ( folder) = self . start_open_path . lock ( ) . unwrap ( ) . clone ( ) else {
493505 return LoadingStatus :: Failed ( "unable to find starting folder" . into ( ) ) ;
494506 } ;
@@ -739,6 +751,8 @@ impl LogViewerApp {
739751 }
740752
741753 fn is_changed_since_last_save ( & mut self ) -> bool {
754+ #[ cfg( feature = "profiling" ) ]
755+ puffin:: profile_scope!( "is_changed_since_last_save" ) ;
742756 let as_ron = match ron:: to_string ( & self ) {
743757 Ok ( s) => s,
744758 Err ( err_msg) => {
@@ -804,8 +818,12 @@ fn execute<F: std::future::Future<Output = Box<LoadingStatus>> + 'static>(
804818impl eframe:: App for LogViewerApp {
805819 /// Called by the frame work to save state before shutdown.
806820 fn save ( & mut self , storage : & mut dyn eframe:: Storage ) {
821+ #[ cfg( feature = "profiling" ) ]
822+ puffin:: profile_scope!( "eframe::App::save" ) ;
807823 if self . is_changed_since_last_save ( ) {
808824 info ! ( "Saving data" ) ;
825+ #[ cfg( feature = "profiling" ) ]
826+ puffin:: profile_scope!( "Saving App State" ) ;
809827 eframe:: set_value ( storage, eframe:: APP_KEY , self ) ;
810828 } else {
811829 debug ! ( "Save skipped, no change detected" ) ;
@@ -814,8 +832,12 @@ impl eframe::App for LogViewerApp {
814832
815833 /// Called each time the UI needs repainting, which may be many times per second.
816834 fn update ( & mut self , ctx : & egui:: Context , _frame : & mut eframe:: Frame ) {
835+ #[ cfg( feature = "profiling" ) ]
836+ puffin:: profile_scope!( "update_loop" ) ;
817837 egui:: TopBottomPanel :: top ( "top_panel" ) . show ( ctx, |ui| {
818838 // The top panel is often a good place for a menu bar:
839+ #[ cfg( feature = "profiling" ) ]
840+ puffin:: profile_scope!( "top_panel" ) ;
819841
820842 self . check_global_shortcuts ( ui) ;
821843
@@ -837,6 +859,8 @@ impl eframe::App for LogViewerApp {
837859
838860 egui:: CentralPanel :: default ( ) . show ( ctx, |ui| {
839861 // The central panel the region left after adding TopPanel's and SidePanel's
862+ #[ cfg( feature = "profiling" ) ]
863+ puffin:: profile_scope!( "outer_central_panel" ) ;
840864 static HEADING : LazyLock < & ' static str > =
841865 LazyLock :: new ( || format ! ( "Log Viewer {}" , env!( "CARGO_PKG_VERSION" ) ) . leak ( ) ) ;
842866 ui. heading ( * HEADING ) ;
@@ -857,6 +881,8 @@ impl eframe::App for LogViewerApp {
857881 . max_height ( max_details_height)
858882 . min_height ( 60. )
859883 . show_inside ( ui, |ui| {
884+ #[ cfg( feature = "profiling" ) ]
885+ puffin:: profile_scope!( "bottom_panel" ) ;
860886 ui. vertical_centered ( |ui| {
861887 ui. heading ( "Details" ) ;
862888 } ) ;
@@ -871,6 +897,8 @@ impl eframe::App for LogViewerApp {
871897 } ) ;
872898
873899 egui:: CentralPanel :: default ( ) . show_inside ( ui, |ui| {
900+ #[ cfg( feature = "profiling" ) ]
901+ puffin:: profile_scope!( "inner_central_panel" ) ;
874902 egui:: ScrollArea :: horizontal ( )
875903 . id_salt ( "log lines" )
876904 . show ( ui, |ui| {
0 commit comments