Skip to content

Commit

Permalink
profiling scopes on all systems and optimize overrides tiny bit
Browse files Browse the repository at this point in the history
  • Loading branch information
Uriopass committed Feb 8, 2024
1 parent 5559a40 commit 93bc319
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 1 deletion.
9 changes: 8 additions & 1 deletion simulation/src/map/height_override.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,17 @@ impl OverrideSetter {
pub fn find_overrides(map: &mut Map, chunk: SubscriberChunkID) {
let mut terrain_affected = BTreeSet::new();

let sub_chunk_bbox = chunk.bbox();

for obj in map.spatial_map.query(
chunk.bbox(),
sub_chunk_bbox,
ProjectFilter::ROAD | ProjectFilter::INTER | ProjectFilter::BUILDING,
) {
// ensure the object is only processed once
if !sub_chunk_bbox.contains(obj.canonical_position(map)) {
continue;
}

let bbox = match obj {
ProjectKind::Inter(i) => {
let i = map.get(i).unwrap();
Expand Down
1 change: 1 addition & 0 deletions simulation/src/map/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ impl Map {

/// Perform cleanups potentially required every frame
pub fn update(&mut self) {
profiling::scope!("map::update");
for chunk in self.override_suscriber.take_updated_chunks() {
find_overrides(self, chunk);
}
Expand Down
2 changes: 2 additions & 0 deletions simulation/src/map_dynamic/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,8 @@ impl DispatchOne {
}

pub fn dispatch_system(world: &mut World, resources: &mut Resources) {
profiling::scope!("map_dynamic::dispatch");

let mut dispatcher = resources.write::<Dispatcher>();
let map = resources.read::<Map>();
dispatcher.update(&map, world);
Expand Down
2 changes: 2 additions & 0 deletions simulation/src/map_dynamic/electricity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ pub struct NetworkFlow {
/// All producing buildings will produce power, and all consuming buildings will consume power
/// If a network produces less power than it consumes, a blackout will occur
pub fn electricity_flow_system(world: &mut World, resources: &mut Resources) {
profiling::scope!("map_dynamic::electricity_flow");

let map = resources.read::<Map>();
let binfos = resources.read::<BuildingInfos>();
let mut flow = resources.write::<ElectricityFlow>();
Expand Down
1 change: 1 addition & 0 deletions simulation/src/souls/freight_station.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ pub fn freight_station_soul(
}

pub fn freight_station_system(world: &mut World, resources: &mut Resources) {
profiling::scope!("souls::freight_station_system");
let cbuf = resources.read::<ParCommandBuffer<FreightStationEnt>>();
let mut dispatch = resources.write::<Dispatcher>();
let map = resources.read::<Map>();
Expand Down
2 changes: 2 additions & 0 deletions simulation/src/transportation/testing_vehicles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ pub struct RandomVehicles {
}

pub fn random_vehicles_update(world: &mut World, res: &mut Resources) {
profiling::scope!("transportation::random_vehicles_update");

let rv = &mut *res.write::<RandomVehicles>();
let map = res.read::<Map>();

Expand Down

0 comments on commit 93bc319

Please sign in to comment.