CatStation/Content.Benchmarks/MapLoadBenchmark.cs
Aaron 5781283a9c
Tramstation (#34191)
* Tram!

* add tram to test file and add prototype

* fixed prototype

* fixed map and prototype

* small changes

* changed dorms and tool room

* Ready for review.
please dont be too harsh i will cry

* Various fixes

medical front, sci front. edited some maints. fixed cramped atmos. added warden bedroom

* small updates

* new maints rooms and small fixes

* i hope this doesnt break anything

* i dont think anyone reads these

* renamed everything

* Firelock 198X is a fun game

tiles under doors, fixed airlock access in parts, more maints stuff. tried to fix tram air

* still no idea how many people belong on this station

* Genpop, silos and more!

* Fixed Sec and atmos pipes

* i am a fool

* sec entrance to genpop. more engi parts and tram adjustments

* everytime i fix something i break something else

* small fixes and tram stuff

* added turrets and attempted to fix mail system

* Resolved most issues from playtest and changed prototype

* small changes

* minor tweaks

* More small fixes

* changes from feedback

* colored pipes

* redid turrets

* small fixes

* chem, comm and other changes

* someone else might need to finish this

* air and power fix in sec

* fixed vault and minor firelocks around the station

* lawyer and map test/pool

* bugfixing

* maint and misc changes

* no more diy teg

* tram speed limited

* changed job roster adn added Tram Driver spawn

* im an idiot

* final changes

* fix tests

* fix tests for real this time

---------

Co-authored-by: ArtisticRoomba <145879011+ArtisticRoomba@users.noreply.github.com>
2026-07-30 03:18:39 +00:00

80 lines
2.4 KiB
C#

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using BenchmarkDotNet.Attributes;
using Content.IntegrationTests;
using Content.IntegrationTests.Pair;
using Content.Shared.Maps;
using Robust.Shared;
using Robust.Shared.Analyzers;
using Robust.Shared.EntitySerialization.Systems;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
namespace Content.Benchmarks;
[Virtual]
public class MapLoadBenchmark
{
private TestPair _pair = default!;
private MapLoaderSystem _mapLoader = default!;
private SharedMapSystem _mapSys = default!;
[GlobalSetup]
public void Setup()
{
ProgramShared.PathOffset = "../../../../";
PoolManager.Startup();
_pair = PoolManager.GetServerClient(testContext: new ExternalTestContext("Benchmark", StreamWriter.Null)).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>();
_mapSys = server.ResolveDependency<IEntitySystemManager>().GetEntitySystem<SharedMapSystem>();
}
[GlobalCleanup]
public async Task Cleanup()
{
await _pair.DisposeAsync();
PoolManager.Shutdown();
}
public static string[] MapsSource { get; } = { "Empty", "Saltern", "Box", "Bagel", "Dev", "CentComm", "Core", "TestTeg", "Packed", "Omega", "Meta", "Marathon", "MeteorArena", "Fland", "Oasis", "Convex", "Tram2"};
[ParamsSource(nameof(MapsSource))]
public string Map;
public Dictionary<string, string> Paths;
private MapId _mapId;
[Benchmark]
public async Task LoadMap()
{
var mapPath = new ResPath(Paths[Map]);
var server = _pair.Server;
await server.WaitPost(() =>
{
var success = _mapLoader.TryLoadMap(mapPath, out var map, out _);
if (!success)
throw new Exception("Map load failed");
_mapId = map.Value.Comp.MapId;
});
}
[IterationCleanup]
public void IterationCleanup()
{
var server = _pair.Server;
server.WaitPost(() => _mapSys.DeleteMap(_mapId))
.Wait();
}
}