mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-06-09 13:26:34 +02:00
d42adbf05d
* Pass 1. * i'm FREE * Prevent hangups. * okay fine here's an attribute for settings, will polish later and prolly remove the overridable thing. * sigh. * fix singular trigger bug so LatheTest doesn't flake. * Remove SystemAttribute usage. * Poke * I used the shotgun. You know why? Cause the shot gun doesn’t miss, and unlike the shitty hybrid taser it stops a criminal in their tracks in two hits. Bang, bang, and they’re fucking done. I use four shots just to make damn sure. Because, once again, I’m not there to coddle a buncha criminal scum sucking f------, I’m there to 1) Survive the fucking round. 2) Guard the armory. So you can absolutely get fucked. If I get unbanned, which I won’t, you can guarantee I will continue to use the shotgun to apprehend criminals. Because it’s quick, clean and effective as fuck. Why in the seven hells would I fuck around with the disabler shots, which take half a clip just to bring someone down, or with the tazer bolts which are slow as balls, impossible to aim and do about next to jack shit, fuck all. The shotgun is the superior law enforcement weapon. Because it stops crime. And it stops crime by reducing the number of criminals roaming the fucking halls. * Change the faulty store test into two tests, one of which is ignored for failing.
144 lines
4.4 KiB
C#
144 lines
4.4 KiB
C#
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Threading.Tasks;
|
|
using BenchmarkDotNet.Attributes;
|
|
using Content.IntegrationTests;
|
|
using Content.IntegrationTests.Pair;
|
|
using Content.IntegrationTests.Tests.DeviceNetwork;
|
|
using Content.Server.DeviceNetwork.Systems;
|
|
using Content.Shared.DeviceNetwork;
|
|
using Robust.Shared;
|
|
using Robust.Shared.Analyzers;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.Map;
|
|
|
|
namespace Content.Benchmarks;
|
|
|
|
[Virtual]
|
|
[MemoryDiagnoser]
|
|
public class DeviceNetworkingBenchmark
|
|
{
|
|
private TestPair _pair = default!;
|
|
private DeviceNetworkTestSystem _deviceNetTestSystem = default!;
|
|
private DeviceNetworkSystem _deviceNetworkSystem = default!;
|
|
private EntityUid _sourceEntity;
|
|
private EntityUid _sourceWirelessEntity;
|
|
private readonly List<EntityUid> _targetEntities = new();
|
|
private readonly List<EntityUid> _targetWirelessEntities = new();
|
|
|
|
|
|
private NetworkPayload _payload = default!;
|
|
|
|
[TestPrototypes]
|
|
private const string Prototypes = @"
|
|
- type: entity
|
|
name: DummyNetworkDevicePrivate
|
|
id: DummyNetworkDevicePrivate
|
|
components:
|
|
- type: DeviceNetwork
|
|
transmitFrequency: 100
|
|
receiveFrequency: 100
|
|
deviceNetId: Private
|
|
- type: entity
|
|
name: DummyWirelessNetworkDevice
|
|
id: DummyWirelessNetworkDevice
|
|
components:
|
|
- type: DeviceNetwork
|
|
transmitFrequency: 100
|
|
receiveFrequency: 100
|
|
deviceNetId: Wireless
|
|
- type: WirelessNetworkConnection
|
|
range: 100
|
|
";
|
|
|
|
//public static IEnumerable<int> EntityCountSource { get; set; }
|
|
|
|
//[ParamsSource(nameof(EntityCountSource))]
|
|
public int EntityCount = 500;
|
|
|
|
[GlobalSetup]
|
|
public async Task SetupAsync()
|
|
{
|
|
ProgramShared.PathOffset = "../../../../";
|
|
PoolManager.Startup(typeof(DeviceNetworkingBenchmark).Assembly);
|
|
_pair = await PoolManager.GetServerClient(testContext: new ExternalTestContext("Benchmark", StreamWriter.Null));
|
|
var server = _pair.Server;
|
|
|
|
await server.WaitPost(() =>
|
|
{
|
|
var entityManager = server.InstanceDependencyCollection.Resolve<IEntityManager>();
|
|
_deviceNetworkSystem = entityManager.EntitySysManager.GetEntitySystem<DeviceNetworkSystem>();
|
|
_deviceNetTestSystem = entityManager.EntitySysManager.GetEntitySystem<DeviceNetworkTestSystem>();
|
|
|
|
var testValue = "test";
|
|
_payload = new NetworkPayload
|
|
{
|
|
["Test"] = testValue,
|
|
["testnumber"] = 1,
|
|
["testbool"] = true
|
|
};
|
|
|
|
_sourceEntity = entityManager.SpawnEntity("DummyNetworkDevicePrivate", MapCoordinates.Nullspace);
|
|
_sourceWirelessEntity = entityManager.SpawnEntity("DummyWirelessNetworkDevice", MapCoordinates.Nullspace);
|
|
|
|
for (var i = 0; i < EntityCount; i++)
|
|
{
|
|
_targetEntities.Add(entityManager.SpawnEntity("DummyNetworkDevicePrivate", MapCoordinates.Nullspace));
|
|
_targetWirelessEntities.Add(entityManager.SpawnEntity("DummyWirelessNetworkDevice", MapCoordinates.Nullspace));
|
|
}
|
|
});
|
|
}
|
|
|
|
[GlobalCleanup]
|
|
public async Task Cleanup()
|
|
{
|
|
await _pair.DisposeAsync();
|
|
PoolManager.Shutdown();
|
|
}
|
|
|
|
[Benchmark(Baseline = true, Description = "Entity Events")]
|
|
public async Task EventSentBaseline()
|
|
{
|
|
var server = _pair.Server;
|
|
|
|
_pair.Server.Post(() =>
|
|
{
|
|
foreach (var entity in _targetEntities)
|
|
{
|
|
_deviceNetTestSystem.SendBaselineTestEvent(entity);
|
|
}
|
|
});
|
|
|
|
await server.WaitRunTicks(1);
|
|
await server.WaitIdleAsync();
|
|
}
|
|
|
|
[Benchmark(Description = "Device Net Broadcast No Connection Checks")]
|
|
public async Task DeviceNetworkBroadcastNoConnectionChecks()
|
|
{
|
|
var server = _pair.Server;
|
|
|
|
_pair.Server.Post(() =>
|
|
{
|
|
_deviceNetworkSystem.QueuePacket(_sourceEntity, null, _payload, 100);
|
|
});
|
|
|
|
await server.WaitRunTicks(1);
|
|
await server.WaitIdleAsync();
|
|
}
|
|
|
|
[Benchmark(Description = "Device Net Broadcast Wireless Connection Checks")]
|
|
public async Task DeviceNetworkBroadcastWirelessConnectionChecks()
|
|
{
|
|
var server = _pair.Server;
|
|
|
|
_pair.Server.Post(() =>
|
|
{
|
|
_deviceNetworkSystem.QueuePacket(_sourceWirelessEntity, null, _payload, 100);
|
|
});
|
|
|
|
await server.WaitRunTicks(1);
|
|
await server.WaitIdleAsync();
|
|
}
|
|
}
|