From d1904f3f3544fbe5bbc8927fb8697e2f616aab54 Mon Sep 17 00:00:00 2001 From: Mike Date: Tue, 10 May 2022 20:18:58 +0000 Subject: [PATCH] Add a tracing span for run criteria. (#4709) # Objective Adds a tracing span for run critieria. This change will be invalidated by stageless, but it was a simple change. Fixes #4681. ## Changelog Shows how long a run criteria takes to run when tracing is enabled. ![image](https://user-images.githubusercontent.com/2180432/167517447-93dba7db-8c85-4686-90e0-30e9636f120f.png) --- crates/bevy_ecs/src/schedule/stage.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/bevy_ecs/src/schedule/stage.rs b/crates/bevy_ecs/src/schedule/stage.rs index 2cf14f0d0097b1..210ac514c2085b 100644 --- a/crates/bevy_ecs/src/schedule/stage.rs +++ b/crates/bevy_ecs/src/schedule/stage.rs @@ -802,6 +802,12 @@ impl Stage for SystemStage { for index in 0..self.run_criteria.len() { let (run_criteria, tail) = self.run_criteria.split_at_mut(index); let mut criteria = &mut tail[0]; + + #[cfg(feature = "trace")] + let _span = + bevy_utils::tracing::info_span!("run criteria", name = &*criteria.name()) + .entered(); + match &mut criteria.inner { RunCriteriaInner::Single(system) => criteria.should_run = system.run((), world), RunCriteriaInner::Piped {