Skip to content

Commit

Permalink
Profile span
Browse files Browse the repository at this point in the history
  • Loading branch information
metalgearsloth committed Oct 29, 2023
1 parent ef771dc commit d6613f4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
11 changes: 10 additions & 1 deletion Robust.Client/Console/Commands/ProfileEntitySpawningCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,25 @@ public void Execute(IConsoleShell shell, string argStr, string[] args)

GC.Collect();

Span<EntityUid> ents = stackalloc EntityUid[amount];
var stopwatch = new Stopwatch();
stopwatch.Start();

MeasureProfiler.StartCollectingData();

_entities.SpawnEntities(MapCoordinates.Nullspace, prototype, amount);
for (var i = 0; i < amount; i++)
{
ents[i] = _entities.SpawnEntity(prototype, MapCoordinates.Nullspace);
}

MeasureProfiler.SaveData();

shell.WriteLine($"Client: Profiled spawning {amount} entities in {stopwatch.Elapsed.TotalMilliseconds:N3} ms");

foreach (var ent in ents)
{
_entities.DeleteEntity(ent);
}
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,25 @@ public void Execute(IConsoleShell shell, string argStr, string[] args)

GC.Collect();

Span<EntityUid> ents = stackalloc EntityUid[amount];
var stopwatch = new Stopwatch();
stopwatch.Start();

MeasureProfiler.StartCollectingData();

for (var i = 0; i < amount; i++)
{
_entities.SpawnEntity(prototype, MapCoordinates.Nullspace);
ents[i] = _entities.SpawnEntity(prototype, MapCoordinates.Nullspace);
}

MeasureProfiler.SaveData();

shell.WriteLine($"Server: Profiled spawning {amount} entities in {stopwatch.Elapsed.TotalMilliseconds:N3} ms");

foreach (var ent in ents)
{
_entities.DeleteEntity(ent);
}
}
}
#endif

0 comments on commit d6613f4

Please sign in to comment.