Files
tbd-station-14/Content.Benchmarks/MapLoadBenchmark.cs
Spessmann 208b1d23b8 Added Cog(map) and its own evac shuttle (#30840)
* Added new map Cog and its own evac shuttle

* removed cog from default.yml so all checks will pass

I added cog here because i thought it might need to be here for map choosing??????????? ill add it back if needed

* updated cog and fixed a bunch of stuff that was not visable in the image, also nerfed the singo so it no longer solos

* added renault spawner that was missing and changed some minor stuff

* moved a escape pod from med/sci hallway to northern maints

* added shutters to the brig and added vents and scrubbers where they were missing in the halls

* extended salv's docking port so they can dock

* Fixed according to cog review thread

* fix pools

* fix PostMapInitTest

* Update MapLoadBenchmark.cs

* added cap and hop spawn that i just forgot to add???????????????????

* fixed again

---------

Co-authored-by: Emisse <99158783+Emisse@users.noreply.github.com>
2024-08-13 13:27:24 -06:00

79 lines
2.2 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using BenchmarkDotNet.Attributes;
using Content.IntegrationTests;
using Content.IntegrationTests.Pair;
using Content.Server.Maps;
using Robust.Server.GameObjects;
using Robust.Shared;
using Robust.Shared.Analyzers;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
namespace Content.Benchmarks;
[Virtual]
public class MapLoadBenchmark
{
private TestPair _pair = default!;
private MapLoaderSystem _mapLoader = default!;
private IMapManager _mapManager = default!;
[GlobalSetup]
public void Setup()
{
ProgramShared.PathOffset = "../../../../";
PoolManager.Startup();
_pair = PoolManager.GetServerClient().GetAwaiter().GetResult();
var server = _pair.Server;
Paths = server.ResolveDependency<IPrototypeManager>()
.EnumeratePrototypes<GameMapPrototype>()
.ToDictionary(x => x.ID, x => x.MapPath.ToString());
_mapLoader = server.ResolveDependency<IEntitySystemManager>().GetEntitySystem<MapLoaderSystem>();
_mapManager = server.ResolveDependency<IMapManager>();
}
[GlobalCleanup]
public async Task Cleanup()
{
await _pair.DisposeAsync();
PoolManager.Shutdown();
}
public static readonly string[] MapsSource = { "Empty", "Box", "Bagel", "Dev", "CentComm", "Atlas", "Core", "TestTeg", "Saltern", "Packed", "Omega", "Cluster", "Reach", "Origin", "Meta", "Marathon", "Europa", "MeteorArena", "Fland", "Barratry", "Oasis", "Cog" };
[ParamsSource(nameof(MapsSource))]
public string Map;
public Dictionary<string, string> Paths;
[Benchmark]
public async Task LoadMap()
{
var mapPath = Paths[Map];
var server = _pair.Server;
await server.WaitPost(() =>
{
var success = _mapLoader.TryLoad(new MapId(10), mapPath, out _);
if (!success)
throw new Exception("Map load failed");
});
}
[IterationCleanup]
public void IterationCleanup()
{
var server = _pair.Server;
server.WaitPost(() =>
{
_mapManager.DeleteMap(new MapId(10));
}).Wait();
}
}