diff --git a/src/entity/builder.rs b/src/entity/builder.rs index 988ad41..5cc8678 100644 --- a/src/entity/builder.rs +++ b/src/entity/builder.rs @@ -149,6 +149,7 @@ impl EntityBuilder { /// Clears the builder and allows it to be used again, reusing the builder /// will reuse the inner storage, even for different components. pub fn spawn(&mut self, world: &mut World) -> Entity { + profile_function!(); let id = world.spawn_with(&mut self.buffer); self.children.drain(..).for_each(|child| { @@ -177,6 +178,7 @@ impl EntityBuilder { /// /// New components will overwrite existing components. pub fn append_to(&mut self, world: &mut World, id: Entity) -> Result { + profile_function!(); world.set_with(id, &mut self.buffer)?; self.children.drain(..).for_each(|child| { diff --git a/src/world.rs b/src/world.rs index c2b13f1..fce5151 100644 --- a/src/world.rs +++ b/src/world.rs @@ -126,17 +126,20 @@ impl World { /// Create an iterator to spawn several entities pub fn spawn_many(&mut self) -> impl Iterator + '_ { + profile_function!(); (0..).map(|_| self.spawn()) } /// Spawn a new empty entity into the default namespace pub fn spawn(&mut self) -> Entity { + profile_function!(); self.spawn_inner(self.archetypes.root, EntityKind::empty()) .0 } /// Spawn a new empty entity and acquire an entity reference. pub fn spawn_ref(&mut self) -> EntityRefMut { + profile_function!(); let (id, loc, _) = self.spawn_inner(self.archetypes.root, EntityKind::empty()); EntityRefMut { world: self, @@ -147,6 +150,7 @@ impl World { /// Efficiently spawn many entities with the same components at once. pub fn spawn_batch(&mut self, chunk: &mut BatchSpawn) -> Vec { + profile_function!(); self.flush_reserved(); for component in chunk.components() { @@ -357,6 +361,7 @@ impl World { /// Despawn an entity. /// Any relations to other entities will be removed. pub fn despawn(&mut self, id: Entity) -> Result<()> { + profile_function!(); self.flush_reserved(); let EntityLocation { arch_id: arch, @@ -395,6 +400,7 @@ impl World { where F: for<'x> Fetch<'x>, { + profile_function!(); self.flush_reserved(); let mut query = Query::new(entity_ids()).filter(filter); let ids = query.borrow(self).iter().collect_vec(); @@ -411,6 +417,7 @@ impl World { id: Entity, relation: impl RelationExt, ) -> Result<()> { + profile_function!(); self.despawn_children(id, relation)?; self.despawn(id)?; @@ -423,6 +430,7 @@ impl World { id: Entity, relation: impl RelationExt, ) -> Result<()> { + profile_function!(); self.flush_reserved(); let mut stack = alloc::vec![id];