experiments/csharp/E054-DivisionBenchmarks/Program.cs

38 lines
734 B
C#
Raw Normal View History

2024-05-04 21:16:52 +01:00
using System.Numerics;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
BenchmarkRunner.Run<DivisionBenchmarks>();
[SimpleJob, MemoryDiagnoser(false)]
public class DivisionBenchmarks
{
[Benchmark]
[Arguments(1.0f)]
public float SingleDivide(float x)
{
return x / 10.0f;
}
[Benchmark]
[Arguments(0.1f)]
public float SingleMultiply(float x)
{
return x * 10.0f;
}
[Benchmark]
[Arguments(10.0f)]
public Vector3 VectorDivide(float y)
{
return new Vector3(10.0f, 10.0f, 10.0f) / y;
}
[Benchmark]
[Arguments(0.1f)]
public Vector3 VectorMultiply(float y)
{
return new Vector3(10.0f, 10.0f, 10.0f) * y;
}
}