mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
Adds a new ResPath struct that will replace ResourcePath (#3663)
This commit is contained in:
47
Robust.Benchmarks/Utility/ResourcePathBench.cs
Normal file
47
Robust.Benchmarks/Utility/ResourcePathBench.cs
Normal 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
|
||||
Reference in New Issue
Block a user