Files
tbd-station-14/Content.Benchmarks/MapLoadBenchmark.cs
IProduceWidgets 7b0b894e44 Add map Oasis (#25736)
* Add map Oasis

* integration test fix

* psych job

* 1984 an invalid component

* address reviews

* address reviews, touch ups.

* tiny feexes

* move a tree

* Actually put it in the active maps pool.

* minor tweeks

* tweek some door accesses.

* add extra lawyer, make evac the right docking arrangement.

* Address the small things, fix cryopods, make perma huge.

* Fix some small things in the new perma.

* Improve perma spacing resiliancy... maybe.

* burn the invalids

* Pray to the Sloth gods that painters arent cooked.

* rearrange some buttons

* fix fax names and add a genedrobe.

* Housekeeping

* fix some stuff I thought I already fixed

* wood benches

* Some under door tiles, a couple missing decals.

* one pipe got brokey. feexit!

* astrograsses and lathe to cargo

* N2 lockers, minor things.

* cap laser to case

* GridFill the briggle so it feels better. Some other minor things

* name the Briggle correctly
2024-04-20 23:59:12 -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(null);
_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" };
[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();
}
}