mirror of
https://github.com/bevyengine/bevy
synced 2025-02-27 12:57:21 +00:00
Merge pull request #204 from multun/fix-profiling-build
profiling: fix build
This commit is contained in:
commit
f92f6a4f9b
6 changed files with 10 additions and 9 deletions
|
@ -10,7 +10,7 @@ license = "MIT"
|
||||||
keywords = ["bevy"]
|
keywords = ["bevy"]
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
profiler = []
|
profiler = ["bevy_ecs/profiler"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# bevy
|
# bevy
|
||||||
|
|
|
@ -19,7 +19,7 @@ impl Plugin for DiagnosticsPlugin {
|
||||||
#[cfg(feature = "profiler")]
|
#[cfg(feature = "profiler")]
|
||||||
{
|
{
|
||||||
use bevy_ecs::IntoQuerySystem;
|
use bevy_ecs::IntoQuerySystem;
|
||||||
app.add_resource::<Box<dyn bevy_ecs::profiler::Profiler>>(Box::new(
|
app.add_resource::<Box<dyn bevy_ecs::Profiler>>(Box::new(
|
||||||
system_profiler::SystemProfiler::default(),
|
system_profiler::SystemProfiler::default(),
|
||||||
))
|
))
|
||||||
.add_system_to_stage(
|
.add_system_to_stage(
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::{Diagnostic, DiagnosticId, Diagnostics};
|
use crate::{Diagnostic, DiagnosticId, Diagnostics};
|
||||||
use bevy_ecs::{profiler::Profiler, Res, ResMut};
|
use bevy_ecs::{Profiler, Res, ResMut};
|
||||||
use std::{
|
use std::{
|
||||||
borrow::Cow,
|
borrow::Cow,
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
|
|
|
@ -19,3 +19,4 @@ rand = "0.7.2"
|
||||||
rayon = "1.3"
|
rayon = "1.3"
|
||||||
crossbeam-channel = "0.4.2"
|
crossbeam-channel = "0.4.2"
|
||||||
fixedbitset = "0.3.0"
|
fixedbitset = "0.3.0"
|
||||||
|
downcast-rs = "1.1.1"
|
||||||
|
|
|
@ -131,9 +131,9 @@ impl Schedule {
|
||||||
for stage_name in self.stage_order.iter() {
|
for stage_name in self.stage_order.iter() {
|
||||||
if let Some(stage_systems) = self.stages.get_mut(stage_name) {
|
if let Some(stage_systems) = self.stages.get_mut(stage_name) {
|
||||||
for system in stage_systems.iter_mut() {
|
for system in stage_systems.iter_mut() {
|
||||||
#[cfg(feature = "profiler")]
|
|
||||||
crate::profiler::profiler_start(resources, system.name().clone());
|
|
||||||
let mut system = system.lock().unwrap();
|
let mut system = system.lock().unwrap();
|
||||||
|
#[cfg(feature = "profiler")]
|
||||||
|
crate::profiler_start(resources, system.name().clone());
|
||||||
system.update_archetype_access(world);
|
system.update_archetype_access(world);
|
||||||
match system.thread_local_execution() {
|
match system.thread_local_execution() {
|
||||||
ThreadLocalExecution::NextFlush => system.run(world, resources),
|
ThreadLocalExecution::NextFlush => system.run(world, resources),
|
||||||
|
@ -144,7 +144,7 @@ impl Schedule {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[cfg(feature = "profiler")]
|
#[cfg(feature = "profiler")]
|
||||||
crate::profiler::profiler_stop(resources, system.name().clone());
|
crate::profiler_stop(resources, system.name().clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
// "flush"
|
// "flush"
|
||||||
|
|
|
@ -11,13 +11,13 @@ pub trait Profiler: Downcast + Send + Sync + 'static {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn profiler_start(resources: &Resources, scope: Cow<'static, str>) {
|
pub fn profiler_start(resources: &Resources, scope: Cow<'static, str>) {
|
||||||
if let Ok(profiler) = resources.get::<Box<dyn Profiler>>() {
|
if let Some(profiler) = resources.get::<Box<dyn Profiler>>() {
|
||||||
profiler.start(scope);
|
profiler.start(scope);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn profiler_stop(resources: &Resources, scope: Cow<'static, str>) {
|
pub fn profiler_stop(resources: &Resources, scope: Cow<'static, str>) {
|
||||||
if let Ok(profiler) = resources.get::<Box<dyn Profiler>>() {
|
if let Some(profiler) = resources.get::<Box<dyn Profiler>>() {
|
||||||
profiler.stop(scope);
|
profiler.stop(scope);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue