Adds a new ResPath struct that will replace ResourcePath (#3663)

This commit is contained in:
Ygg01
2023-04-11 03:18:42 +02:00
committed by GitHub
parent 42a4227efe
commit 951e01af5a
7 changed files with 853 additions and 262 deletions

View File

@@ -0,0 +1,47 @@
using BenchmarkDotNet.Attributes;
using JetBrains.Annotations;
using Robust.Shared.Analyzers;
using Robust.Shared.Utility;
#pragma warning disable CS0612
namespace Robust.Benchmarks.Utility;
[Virtual]
public class ResourcePathBench
{
private string _path = default!;
[UsedImplicitly]
[Params(10, 100, 1000)]
public int N;
[GlobalSetup]
public void GlobalSetup()
{
_path = "/a/b/c/../test";
}
[Benchmark]
public ResPath CreateWithSeparatorResPath()
{
ResPath res = default;
for (var i = 0; i < N; i++)
{
res = new ResPath(_path);
}
return res;
}
[Benchmark]
public ResourcePath? CreateResourcePath()
{
ResourcePath? res = null;
for (var i = 0; i < N; i++)
{
res = new ResourcePath(_path);
}
return res;
}
}
#pragma warning restore CS0612