Skip to content

Commit 277160e

Browse files
committed
fix: only run profiling on native client
1 parent 2ae7f54 commit 277160e

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

src/app.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ impl LogViewerApp {
9898
}
9999

100100
fn show_log_lines(&mut self, ui: &mut egui::Ui) {
101-
#[cfg(feature = "profiling")]
101+
#[cfg(all(not(target_arch = "wasm32"), feature = "profiling"))]
102102
puffin::profile_scope!("show_log_lines");
103103
let text_height = egui::TextStyle::Body
104104
.resolve(ui.style())
@@ -227,7 +227,7 @@ impl LogViewerApp {
227227
}
228228

229229
fn show_log_details(&mut self, ui: &mut egui::Ui) {
230-
#[cfg(feature = "profiling")]
230+
#[cfg(all(not(target_arch = "wasm32"), feature = "profiling"))]
231231
puffin::profile_scope!("show_log_details");
232232
let Some(data) = self.data.as_mut() else {
233233
ui.label("No data");
@@ -324,7 +324,7 @@ impl LogViewerApp {
324324
self.loading_status = match Data::try_from((&self.data_display_options, &data[..]))
325325
{
326326
Ok(mut data) => {
327-
#[cfg(feature = "profiling")]
327+
#[cfg(all(not(target_arch = "wasm32"), feature = "profiling"))]
328328
puffin::profile_scope!("swap_data_after_load");
329329
if let Some(old_data) = self.data.as_mut() {
330330
// Preserve settings across loads of the data
@@ -514,7 +514,7 @@ impl LogViewerApp {
514514
#[cfg(not(target_arch = "wasm32"))]
515515
/// Attempts to read the contents of the last loaded file and return it in a loading status otherwise returns an error loading status
516516
fn reload_file(&self) -> LoadingStatus {
517-
#[cfg(feature = "profiling")]
517+
#[cfg(all(not(target_arch = "wasm32"), feature = "profiling"))]
518518
puffin::profile_scope!("reload_file");
519519
// TODO 5: Determine if this should spawn a task to do the load
520520
let Some(folder) = self.start_open_path.lock().unwrap().clone() else {
@@ -532,7 +532,7 @@ impl LogViewerApp {
532532

533533
#[cfg(not(target_arch = "wasm32"))]
534534
fn load_most_recent_file(&self) -> LoadingStatus {
535-
#[cfg(feature = "profiling")]
535+
#[cfg(all(not(target_arch = "wasm32"), feature = "profiling"))]
536536
puffin::profile_scope!("load_most_recent_file");
537537
// TODO 5: Determine if this should spawn a task to do the load (might be able to reuse the normal load)
538538
let Some(folder) = self.start_open_path.lock().unwrap().clone() else {
@@ -791,7 +791,7 @@ impl LogViewerApp {
791791
}
792792

793793
fn is_changed_since_last_save(&mut self) -> bool {
794-
#[cfg(feature = "profiling")]
794+
#[cfg(all(not(target_arch = "wasm32"), feature = "profiling"))]
795795
puffin::profile_scope!("is_changed_since_last_save");
796796
let as_ron = match ron::to_string(&self) {
797797
Ok(s) => s,
@@ -871,11 +871,11 @@ fn execute<F: std::future::Future<Output = Box<LoadingStatus>> + 'static>(
871871
impl eframe::App for LogViewerApp {
872872
/// Called by the frame work to save state before shutdown.
873873
fn save(&mut self, storage: &mut dyn eframe::Storage) {
874-
#[cfg(feature = "profiling")]
874+
#[cfg(all(not(target_arch = "wasm32"), feature = "profiling"))]
875875
puffin::profile_scope!("eframe::App::save");
876876
if self.should_save() {
877877
info!("Saving data");
878-
#[cfg(feature = "profiling")]
878+
#[cfg(all(not(target_arch = "wasm32"), feature = "profiling"))]
879879
puffin::profile_scope!("Saving App State");
880880
eframe::set_value(storage, eframe::APP_KEY, self);
881881
} else {
@@ -885,11 +885,11 @@ impl eframe::App for LogViewerApp {
885885

886886
/// Called each time the UI needs repainting, which may be many times per second.
887887
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
888-
#[cfg(feature = "profiling")]
888+
#[cfg(all(not(target_arch = "wasm32"), feature = "profiling"))]
889889
puffin::profile_scope!("update_loop");
890890
egui::TopBottomPanel::top("top_panel").show(ctx, |ui| {
891891
// The top panel is often a good place for a menu bar:
892-
#[cfg(feature = "profiling")]
892+
#[cfg(all(not(target_arch = "wasm32"), feature = "profiling"))]
893893
puffin::profile_scope!("top_panel");
894894

895895
self.check_global_shortcuts(ui);
@@ -912,7 +912,7 @@ impl eframe::App for LogViewerApp {
912912

913913
egui::CentralPanel::default().show(ctx, |ui| {
914914
// The central panel the region left after adding TopPanel's and SidePanel's
915-
#[cfg(feature = "profiling")]
915+
#[cfg(all(not(target_arch = "wasm32"), feature = "profiling"))]
916916
puffin::profile_scope!("outer_central_panel");
917917
static HEADING: LazyLock<&'static str> =
918918
LazyLock::new(|| format!("Log Viewer {}", env!("CARGO_PKG_VERSION")).leak());
@@ -934,7 +934,7 @@ impl eframe::App for LogViewerApp {
934934
.max_height(max_details_height)
935935
.min_height(60.)
936936
.show_inside(ui, |ui| {
937-
#[cfg(feature = "profiling")]
937+
#[cfg(all(not(target_arch = "wasm32"), feature = "profiling"))]
938938
puffin::profile_scope!("bottom_panel");
939939
ui.vertical_centered(|ui| {
940940
ui.heading("Details");
@@ -950,7 +950,7 @@ impl eframe::App for LogViewerApp {
950950
});
951951

952952
egui::CentralPanel::default().show_inside(ui, |ui| {
953-
#[cfg(feature = "profiling")]
953+
#[cfg(all(not(target_arch = "wasm32"), feature = "profiling"))]
954954
puffin::profile_scope!("inner_central_panel");
955955
egui::ScrollArea::horizontal()
956956
.id_salt("log lines")

src/app/data.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ impl Data {
317317
}
318318

319319
pub(crate) fn row_heights(&self, text_height: f32) -> impl Iterator<Item = f32> {
320-
#[cfg(feature = "profiling")]
320+
#[cfg(all(not(target_arch = "wasm32"),feature = "profiling"))]
321321
puffin::profile_scope!("calculate row heights");
322322
// TODO 5: See if this is taking too long and cache value instead of recalculating each frame
323323
self.rows_iter()

src/main.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ async fn main() -> eframe::Result<()> {
3232
),
3333
..Default::default()
3434
};
35-
#[cfg(feature = "profiling")]
35+
#[cfg(all(not(target_arch = "wasm32"), feature = "profiling"))]
3636
start_puffin_server();
3737

3838
eframe::run_native(
@@ -89,7 +89,7 @@ fn main() {
8989
});
9090
}
9191

92-
#[cfg(feature = "profiling")]
92+
#[cfg(all(not(target_arch = "wasm32"), feature = "profiling"))]
9393
fn start_puffin_server() {
9494
puffin::set_scopes_on(true); // tell puffin to collect data
9595

0 commit comments

Comments
 (0)