Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
<PackageVersion Include="prometheus-net.DotNetRuntime" Version="4.4.1" />
<PackageVersion Include="PolySharp" Version="1.15.0" />
<PackageVersion Include="System.CommandLine" Version="2.0.1" />
<PackageVersion Include="System.Numerics.Tensors" Version="10.0.4" />
<!-- Transitive deps that we need to pin versions for to avoid NuGet warnings. -->
<PackageVersion Include="System.Formats.Asn1" Version="10.0.0" />
<PackageVersion Include="System.Reflection.Metadata" Version="10.0.0" />
Expand Down
20 changes: 14 additions & 6 deletions Robust.Benchmarks/NumericsHelpers/AddBenchmark.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
using BenchmarkDotNet.Attributes;
using System.Numerics.Tensors;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using Robust.Shared.Analyzers;

namespace Robust.Benchmarks.NumericsHelpers;

[Virtual]
[GroupBenchmarksBy(BenchmarkLogicalGroupRule.ByMethod)]
[MemoryDiagnoser]
[DisassemblyDiagnoser]
public class AddBenchmark
{
[Params(32, 128)]
[Params(32, 128, 256, 512, 1024, 2048, 4096, 8192, 16384)]
public int N { get; set; }

[Params(1,2)]
public int T { get; set; }

private float[] _inputA = default!;
private float[] _inputB = default!;
private float[] _output = default!;
Expand All @@ -25,8 +27,14 @@ public void Setup()
}

[Benchmark]
public void Bench()
public void BenchNumericsHelpers()
{
Shared.Maths.NumericsHelpers.Add(_inputA, _inputB, _output);
}

[Benchmark]
public void BenchTensor()
{
TensorPrimitives.Add(_inputA, _inputB, _output);
}
}
2 changes: 2 additions & 0 deletions Robust.Benchmarks/Robust.Benchmarks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
<PackageReference Include="BenchmarkDotNet" PrivateAssets="none" />

<PackageReference Include="JetBrains.Annotations" />

<PackageReference Include="System.Numerics.Tensors" />
<PackageReference Include="YamlDotNet" />
<PackageReference Include="prometheus-net" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design">
Expand Down
2 changes: 2 additions & 0 deletions Robust.Shared/ContentPack/Sandbox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,8 @@ Types:
Vector2: { All: True }
Vector3: { All: True }
Vector4: { All: True }
System.Numerics.Tensors:
TensorPrimitives: { All: True }
System.Reflection:
Assembly:
Methods:
Expand Down
1 change: 1 addition & 0 deletions Robust.Shared/Robust.Shared.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" />
<PackageReference Include="Nett" PrivateAssets="compile" />
<PackageReference Include="System.Management" />
<PackageReference Include="System.Numerics.Tensors" />
<PackageReference Include="VorbisPizza" PrivateAssets="compile" />
<PackageReference Include="Pidgin" />
<PackageReference Include="prometheus-net" />
Expand Down
Loading