]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix MapLoadBenchmark
authorElectroJr <leonsfriedrich@gmail.com>
Mon, 23 Dec 2024 05:02:46 +0000 (18:02 +1300)
committerElectroJr <leonsfriedrich@gmail.com>
Mon, 23 Dec 2024 05:02:58 +0000 (18:02 +1300)
Content.Benchmarks/MapLoadBenchmark.cs

index 8c04d9a40dcd1bf0b02310ec07b5882de5dff3b5..abf99f9836f40f5dec881fd2aa656c8f6e96d883 100644 (file)
@@ -6,12 +6,13 @@ 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.EntitySerialization.Systems;
 using Robust.Shared.GameObjects;
 using Robust.Shared.Map;
 using Robust.Shared.Prototypes;
+using Robust.Shared.Utility;
 
 namespace Content.Benchmarks;
 
@@ -20,7 +21,7 @@ public class MapLoadBenchmark
 {
     private TestPair _pair = default!;
     private MapLoaderSystem _mapLoader = default!;
-    private IMapManager _mapManager = default!;
+    private SharedMapSystem _mapSys = default!;
 
     [GlobalSetup]
     public void Setup()
@@ -36,7 +37,7 @@ public class MapLoadBenchmark
             .ToDictionary(x => x.ID, x => x.MapPath.ToString());
 
         _mapLoader = server.ResolveDependency<IEntitySystemManager>().GetEntitySystem<MapLoaderSystem>();
-        _mapManager = server.ResolveDependency<IMapManager>();
+        _mapSys = server.ResolveDependency<IEntitySystemManager>().GetEntitySystem<SharedMapSystem>();
     }
 
     [GlobalCleanup]
@@ -52,17 +53,19 @@ public class MapLoadBenchmark
     public string Map;
 
     public Dictionary<string, string> Paths;
+    private MapId _mapId;
 
     [Benchmark]
     public async Task LoadMap()
     {
-        var mapPath = Paths[Map];
+        var mapPath = new ResPath(Paths[Map]);
         var server = _pair.Server;
         await server.WaitPost(() =>
         {
-            var success = _mapLoader.TryLoad(new MapId(10), mapPath, out _);
+            var success = _mapLoader.TryLoadMap(mapPath, out var map, out _);
             if (!success)
                 throw new Exception("Map load failed");
+            _mapId = map.Value.Comp.MapId;
         });
     }
 
@@ -70,9 +73,7 @@ public class MapLoadBenchmark
     public void IterationCleanup()
     {
         var server = _pair.Server;
-        server.WaitPost(() =>
-        {
-            _mapManager.DeleteMap(new MapId(10));
-        }).Wait();
+        server.WaitPost(() => _mapSys.DeleteMap(_mapId))
+            .Wait();
     }
 }