summaryrefslogtreecommitdiff
path: root/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single
diff options
context:
space:
mode:
Diffstat (limited to 'tests/src/JIT/Performance/CodeQuality/Math/Functions/Single')
-rw-r--r--tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/AbsSingle.cs2
-rw-r--r--tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/AcosSingle.cs47
-rw-r--r--tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/AsinSingle.cs47
-rw-r--r--tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/Atan2Single.cs48
-rw-r--r--tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/AtanSingle.cs47
-rw-r--r--tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/CeilingSingle.cs47
-rw-r--r--tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/CosSingle.cs47
-rw-r--r--tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/CoshSingle.cs47
-rw-r--r--tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/ExpSingle.cs47
-rw-r--r--tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/FloorSingle.cs47
-rw-r--r--tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/Log10Single.cs47
-rw-r--r--tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/LogSingle.cs48
-rw-r--r--tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/PowSingle.cs48
-rw-r--r--tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/RoundSingle.cs47
-rw-r--r--tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/SinSingle.cs47
-rw-r--r--tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/SinhSingle.cs47
-rw-r--r--tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/SqrtSingle.cs47
-rw-r--r--tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/TanSingle.cs47
-rw-r--r--tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/TanhSingle.cs47
19 files changed, 850 insertions, 1 deletions
diff --git a/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/AbsSingle.cs b/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/AbsSingle.cs
index 6168991297..8100c37e1d 100644
--- a/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/AbsSingle.cs
+++ b/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/AbsSingle.cs
@@ -40,7 +40,7 @@ namespace Functions
if (diff > singleEpsilon)
{
- throw new Exception($"Expected Result {absSingleExpectedResult}; Actual Result {result}");
+ throw new Exception($"Expected Result {absSingleExpectedResult,10:g9}; Actual Result {result,10:g9}");
}
}
}
diff --git a/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/AcosSingle.cs b/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/AcosSingle.cs
new file mode 100644
index 0000000000..b958cc1bb4
--- /dev/null
+++ b/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/AcosSingle.cs
@@ -0,0 +1,47 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using Microsoft.Xunit.Performance;
+
+namespace Functions
+{
+ public static partial class MathTests
+ {
+ // Tests MathF.Acos(float) over 5000 iterations for the domain -1, +1
+
+ private const float acosSingleDelta = 0.0004f;
+ private const float acosSingleExpectedResult = 7852.41084f;
+
+ [Benchmark]
+ public static void AcosSingleBenchmark()
+ {
+ foreach (var iteration in Benchmark.Iterations)
+ {
+ using (iteration.StartMeasurement())
+ {
+ AcosSingleTest();
+ }
+ }
+ }
+
+ public static void AcosSingleTest()
+ {
+ var result = 0.0f; var value = -1.0f;
+
+ for (var iteration = 0; iteration < iterations; iteration++)
+ {
+ value += acosSingleDelta;
+ result += MathF.Acos(value);
+ }
+
+ var diff = MathF.Abs(acosSingleExpectedResult - result);
+
+ if (diff > singleEpsilon)
+ {
+ throw new Exception($"Expected Result {acosSingleExpectedResult,10:g9}; Actual Result {result,10:g9}");
+ }
+ }
+ }
+}
diff --git a/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/AsinSingle.cs b/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/AsinSingle.cs
new file mode 100644
index 0000000000..917c49288f
--- /dev/null
+++ b/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/AsinSingle.cs
@@ -0,0 +1,47 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using Microsoft.Xunit.Performance;
+
+namespace Functions
+{
+ public static partial class MathTests
+ {
+ // Tests MathF.Asin(float) over 5000 iterations for the domain -1, +1
+
+ private const float asinSingleDelta = 0.0004f;
+ private const float asinSingleExpectedResult = 1.57079590f;
+
+ [Benchmark]
+ public static void AsinSingleBenchmark()
+ {
+ foreach (var iteration in Benchmark.Iterations)
+ {
+ using (iteration.StartMeasurement())
+ {
+ AsinSingleTest();
+ }
+ }
+ }
+
+ public static void AsinSingleTest()
+ {
+ var result = 0.0f; var value = -1.0f;
+
+ for (var iteration = 0; iteration < iterations; iteration++)
+ {
+ value += asinSingleDelta;
+ result += MathF.Asin(value);
+ }
+
+ var diff = MathF.Abs(asinSingleExpectedResult - result);
+
+ if (diff > singleEpsilon)
+ {
+ throw new Exception($"Expected Result {asinSingleExpectedResult,10:g9}; Actual Result {result,10:g9}");
+ }
+ }
+ }
+}
diff --git a/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/Atan2Single.cs b/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/Atan2Single.cs
new file mode 100644
index 0000000000..a3a4577947
--- /dev/null
+++ b/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/Atan2Single.cs
@@ -0,0 +1,48 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using Microsoft.Xunit.Performance;
+
+namespace Functions
+{
+ public static partial class MathTests
+ {
+ // Tests MathF.Atan2(float, float) over 5000 iterations for the domain y: -1, +1; x: +1, -1
+
+ private const float atan2SingleDeltaX = -0.0004f;
+ private const float atan2SingleDeltaY = 0.0004f;
+ private const float atan2SingleExpectedResult = 3930.14282f;
+
+ [Benchmark]
+ public static void Atan2SingleBenchmark()
+ {
+ foreach (var iteration in Benchmark.Iterations)
+ {
+ using (iteration.StartMeasurement())
+ {
+ Atan2SingleTest();
+ }
+ }
+ }
+
+ public static void Atan2SingleTest()
+ {
+ var result = 0.0f; var valueX = 1.0f; var valueY = -1.0f;
+
+ for (var iteration = 0; iteration < iterations; iteration++)
+ {
+ valueX += atan2SingleDeltaX; valueY += atan2SingleDeltaY;
+ result += MathF.Atan2(valueY, valueX);
+ }
+
+ var diff = MathF.Abs(atan2SingleExpectedResult - result);
+
+ if (diff > singleEpsilon)
+ {
+ throw new Exception($"Expected Result {atan2SingleExpectedResult,10:g9}; Actual Result {result,10:g9}");
+ }
+ }
+ }
+}
diff --git a/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/AtanSingle.cs b/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/AtanSingle.cs
new file mode 100644
index 0000000000..95cc0e226e
--- /dev/null
+++ b/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/AtanSingle.cs
@@ -0,0 +1,47 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using Microsoft.Xunit.Performance;
+
+namespace Functions
+{
+ public static partial class MathTests
+ {
+ // Tests MathF.Atan(float) over 5000 iterations for the domain -1, +1
+
+ private const float atanSingleDelta = 0.0004f;
+ private const float atanSingleExpectedResult = 0.841940999f;
+
+ [Benchmark]
+ public static void AtanSingleBenchmark()
+ {
+ foreach (var iteration in Benchmark.Iterations)
+ {
+ using (iteration.StartMeasurement())
+ {
+ AtanSingleTest();
+ }
+ }
+ }
+
+ public static void AtanSingleTest()
+ {
+ var result = 0.0f; var value = -1.0f;
+
+ for (var iteration = 0; iteration < iterations; iteration++)
+ {
+ value += atanSingleDelta;
+ result += MathF.Atan(value);
+ }
+
+ var diff = MathF.Abs(atanSingleExpectedResult - result);
+
+ if (diff > singleEpsilon)
+ {
+ throw new Exception($"Expected Result {atanSingleExpectedResult,10:g9}; Actual Result {result,10:g9}");
+ }
+ }
+ }
+}
diff --git a/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/CeilingSingle.cs b/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/CeilingSingle.cs
new file mode 100644
index 0000000000..85454f1cc8
--- /dev/null
+++ b/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/CeilingSingle.cs
@@ -0,0 +1,47 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using Microsoft.Xunit.Performance;
+
+namespace Functions
+{
+ public static partial class MathTests
+ {
+ // Tests MathF.Ceiling(float) over 5000 iterations for the domain -1, +1
+
+ private const float ceilingSingleDelta = 0.0004f;
+ private const float ceilingSingleExpectedResult = 2502.0f;
+
+ [Benchmark]
+ public static void CeilingSingleBenchmark()
+ {
+ foreach (var iteration in Benchmark.Iterations)
+ {
+ using (iteration.StartMeasurement())
+ {
+ CeilingSingleTest();
+ }
+ }
+ }
+
+ public static void CeilingSingleTest()
+ {
+ var result = 0.0f; var value = -1.0f;
+
+ for (var iteration = 0; iteration < iterations; iteration++)
+ {
+ value += ceilingSingleDelta;
+ result += MathF.Ceiling(value);
+ }
+
+ var diff = MathF.Abs(ceilingSingleExpectedResult - result);
+
+ if (diff > singleEpsilon)
+ {
+ throw new Exception($"Expected Result {ceilingSingleExpectedResult,10:g9}; Actual Result {result,10:g9}");
+ }
+ }
+ }
+}
diff --git a/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/CosSingle.cs b/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/CosSingle.cs
new file mode 100644
index 0000000000..3d1d6a3b58
--- /dev/null
+++ b/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/CosSingle.cs
@@ -0,0 +1,47 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using Microsoft.Xunit.Performance;
+
+namespace Functions
+{
+ public static partial class MathTests
+ {
+ // Tests MathF.Cos(float) over 5000 iterations for the domain 0, PI
+
+ private const float cosSingleDelta = 0.000628318531f;
+ private const float cosSingleExpectedResult = -0.993487537f;
+
+ [Benchmark]
+ public static void CosSingleBenchmark()
+ {
+ foreach (var iteration in Benchmark.Iterations)
+ {
+ using (iteration.StartMeasurement())
+ {
+ CosSingleTest();
+ }
+ }
+ }
+
+ public static void CosSingleTest()
+ {
+ var result = 0.0f; var value = 0.0f;
+
+ for (var iteration = 0; iteration < iterations; iteration++)
+ {
+ value += cosSingleDelta;
+ result += MathF.Cos(value);
+ }
+
+ var diff = MathF.Abs(cosSingleExpectedResult - result);
+
+ if (diff > singleEpsilon)
+ {
+ throw new Exception($"Expected Result {cosSingleExpectedResult,10:g9}; Actual Result {result,10:g9}");
+ }
+ }
+ }
+}
diff --git a/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/CoshSingle.cs b/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/CoshSingle.cs
new file mode 100644
index 0000000000..072a0dcf66
--- /dev/null
+++ b/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/CoshSingle.cs
@@ -0,0 +1,47 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using Microsoft.Xunit.Performance;
+
+namespace Functions
+{
+ public static partial class MathTests
+ {
+ // Tests MathF.Cosh(float) over 5000 iterations for the domain -1, +1
+
+ private const float coshSingleDelta = 0.0004f;
+ private const float coshSingleExpectedResult = 5876.02588f;
+
+ [Benchmark]
+ public static void CoshSingleBenchmark()
+ {
+ foreach (var iteration in Benchmark.Iterations)
+ {
+ using (iteration.StartMeasurement())
+ {
+ CoshSingleTest();
+ }
+ }
+ }
+
+ public static void CoshSingleTest()
+ {
+ var result = 0.0f; var value = -1.0f;
+
+ for (var iteration = 0; iteration < iterations; iteration++)
+ {
+ value += coshSingleDelta;
+ result += MathF.Cosh(value);
+ }
+
+ var diff = MathF.Abs(coshSingleExpectedResult - result);
+
+ if (diff > singleEpsilon)
+ {
+ throw new Exception($"Expected Result {coshSingleExpectedResult,10:g9}; Actual Result {result,10:g9}");
+ }
+ }
+ }
+}
diff --git a/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/ExpSingle.cs b/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/ExpSingle.cs
new file mode 100644
index 0000000000..e9d61c9f5d
--- /dev/null
+++ b/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/ExpSingle.cs
@@ -0,0 +1,47 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using Microsoft.Xunit.Performance;
+
+namespace Functions
+{
+ public static partial class MathTests
+ {
+ // Tests MathF.Exp(float) over 5000 iterations for the domain -1, +1
+
+ private const float expSingleDelta = 0.0004f;
+ private const float expSingleExpectedResult = 5877.28564f;
+
+ [Benchmark]
+ public static void ExpSingleBenchmark()
+ {
+ foreach (var iteration in Benchmark.Iterations)
+ {
+ using (iteration.StartMeasurement())
+ {
+ ExpSingleTest();
+ }
+ }
+ }
+
+ public static void ExpSingleTest()
+ {
+ var result = 0.0f; var value = -1.0f;
+
+ for (var iteration = 0; iteration < iterations; iteration++)
+ {
+ value += expSingleDelta;
+ result += MathF.Exp(value);
+ }
+
+ var diff = MathF.Abs(expSingleExpectedResult - result);
+
+ if (diff > singleEpsilon)
+ {
+ throw new Exception($"Expected Result {expSingleExpectedResult,10:g9}; Actual Result {result,10:g9}");
+ }
+ }
+ }
+}
diff --git a/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/FloorSingle.cs b/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/FloorSingle.cs
new file mode 100644
index 0000000000..ce1febb178
--- /dev/null
+++ b/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/FloorSingle.cs
@@ -0,0 +1,47 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using Microsoft.Xunit.Performance;
+
+namespace Functions
+{
+ public static partial class MathTests
+ {
+ // Tests MathF.Floor(float) over 5000 iterations for the domain -1, +1
+
+ private const float floorSingleDelta = 0.0004f;
+ private const float floorSingleExpectedResult = -2498.0f;
+
+ [Benchmark]
+ public static void FloorSingleBenchmark()
+ {
+ foreach (var iteration in Benchmark.Iterations)
+ {
+ using (iteration.StartMeasurement())
+ {
+ FloorSingleTest();
+ }
+ }
+ }
+
+ public static void FloorSingleTest()
+ {
+ var result = 0.0f; var value = -1.0f;
+
+ for (var iteration = 0; iteration < iterations; iteration++)
+ {
+ value += floorSingleDelta;
+ result += MathF.Floor(value);
+ }
+
+ var diff = MathF.Abs(floorSingleExpectedResult - result);
+
+ if (diff > singleEpsilon)
+ {
+ throw new Exception($"Expected Result {floorSingleExpectedResult,10:g9}; Actual Result {result,10:g9}");
+ }
+ }
+ }
+}
diff --git a/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/Log10Single.cs b/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/Log10Single.cs
new file mode 100644
index 0000000000..80f00b3ec8
--- /dev/null
+++ b/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/Log10Single.cs
@@ -0,0 +1,47 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using Microsoft.Xunit.Performance;
+
+namespace Functions
+{
+ public static partial class MathTests
+ {
+ // Tests MathF.Log10(float) over 5000 iterations for the domain -1, +1
+
+ private const float log10SingleDelta = 0.0004f;
+ private const float log10SingleExpectedResult = -664.094971f;
+
+ [Benchmark]
+ public static void Log10SingleBenchmark()
+ {
+ foreach (var iteration in Benchmark.Iterations)
+ {
+ using (iteration.StartMeasurement())
+ {
+ Log10SingleTest();
+ }
+ }
+ }
+
+ public static void Log10SingleTest()
+ {
+ var result = 0.0f; var value = 0.0f;
+
+ for (var iteration = 0; iteration < iterations; iteration++)
+ {
+ value += log10SingleDelta;
+ result += MathF.Log10(value);
+ }
+
+ var diff = MathF.Abs(log10SingleExpectedResult - result);
+
+ if (diff > singleEpsilon)
+ {
+ throw new Exception($"Expected Result {log10SingleExpectedResult,10:g9}; Actual Result {result,10:g9}");
+ }
+ }
+ }
+}
diff --git a/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/LogSingle.cs b/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/LogSingle.cs
new file mode 100644
index 0000000000..3f07ef16ab
--- /dev/null
+++ b/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/LogSingle.cs
@@ -0,0 +1,48 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using Microsoft.Xunit.Performance;
+
+namespace Functions
+{
+ public static partial class MathTests
+ {
+ // Tests MathF.Log(float) over 5000 iterations for the domain -1, +1
+
+ private const float logSingleDelta = 0.0004f;
+ private const float logSingleExpectedResult = -1529.14014f;
+
+ [Benchmark]
+ public static void LogSingleBenchmark()
+ {
+ foreach (var iteration in Benchmark.Iterations)
+ {
+ using (iteration.StartMeasurement())
+ {
+ LogSingleTest();
+ }
+ }
+ }
+
+ public static void LogSingleTest()
+ {
+ var result = 0.0f; var value = 0.0f;
+
+ for (var iteration = 0; iteration < iterations; iteration++)
+ {
+ value += logSingleDelta;
+ result += MathF.Log(value);
+ }
+
+ var diff = MathF.Abs(logSingleExpectedResult - result);
+
+ if (diff > singleEpsilon)
+ {
+ throw new Exception($"Expected Result {logSingleExpectedResult,10:g9}; Actual Result {result,10:g9}");
+ }
+ }
+ }
+
+}
diff --git a/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/PowSingle.cs b/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/PowSingle.cs
new file mode 100644
index 0000000000..49de8a0101
--- /dev/null
+++ b/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/PowSingle.cs
@@ -0,0 +1,48 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using Microsoft.Xunit.Performance;
+
+namespace Functions
+{
+ public static partial class MathTests
+ {
+ // Tests MathF.Pow(float, float) over 5000 iterations for the domain x: +2, +1; y: -2, -1
+
+ private const float powSingleDeltaX = -0.0004f;
+ private const float powSingleDeltaY = 0.0004f;
+ private const float powSingleExpectedResult = 4659.30762f;
+
+ [Benchmark]
+ public static void PowSingleBenchmark()
+ {
+ foreach (var iteration in Benchmark.Iterations)
+ {
+ using (iteration.StartMeasurement())
+ {
+ PowSingleTest();
+ }
+ }
+ }
+
+ public static void PowSingleTest()
+ {
+ var result = 0.0f; var valueX = 2.0f; var valueY = -2.0f;
+
+ for (var iteration = 0; iteration < iterations; iteration++)
+ {
+ valueX += powSingleDeltaX; valueY += powSingleDeltaY;
+ result += MathF.Pow(valueX, valueY);
+ }
+
+ var diff = MathF.Abs(powSingleExpectedResult - result);
+
+ if (diff > singleEpsilon)
+ {
+ throw new Exception($"Expected Result {powSingleExpectedResult,10:g9}; Actual Result {result,10:g9}");
+ }
+ }
+ }
+}
diff --git a/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/RoundSingle.cs b/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/RoundSingle.cs
new file mode 100644
index 0000000000..b494a2a985
--- /dev/null
+++ b/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/RoundSingle.cs
@@ -0,0 +1,47 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using Microsoft.Xunit.Performance;
+
+namespace Functions
+{
+ public static partial class MathTests
+ {
+ // Tests MathF.Round(float) over 5000 iterations for the domain -PI/2, +PI/2
+
+ private const float roundSingleDelta = 0.000628318531f;
+ private const float roundSingleExpectedResult = 2.0f;
+
+ [Benchmark]
+ public static void RoundSingleBenchmark()
+ {
+ foreach (var iteration in Benchmark.Iterations)
+ {
+ using (iteration.StartMeasurement())
+ {
+ RoundSingleTest();
+ }
+ }
+ }
+
+ public static void RoundSingleTest()
+ {
+ var result = 0.0f; var value = -1.57079633f;
+
+ for (var iteration = 0; iteration < iterations; iteration++)
+ {
+ value += roundSingleDelta;
+ result += MathF.Round(value);
+ }
+
+ var diff = MathF.Abs(roundSingleExpectedResult - result);
+
+ if (diff > singleEpsilon)
+ {
+ throw new Exception($"Expected Result {roundSingleExpectedResult,10:g9}; Actual Result {result,10:g9}");
+ }
+ }
+ }
+}
diff --git a/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/SinSingle.cs b/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/SinSingle.cs
new file mode 100644
index 0000000000..4d6228361e
--- /dev/null
+++ b/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/SinSingle.cs
@@ -0,0 +1,47 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using Microsoft.Xunit.Performance;
+
+namespace Functions
+{
+ public static partial class MathTests
+ {
+ // Tests MathF.Sin(float) over 5000 iterations for the domain -PI/2, +PI/2
+
+ private const float sinSingleDelta = 0.000628318531f;
+ private const float sinSingleExpectedResult = 1.03592682f;
+
+ [Benchmark]
+ public static void SinSingleBenchmark()
+ {
+ foreach (var iteration in Benchmark.Iterations)
+ {
+ using (iteration.StartMeasurement())
+ {
+ SinSingleTest();
+ }
+ }
+ }
+
+ public static void SinSingleTest()
+ {
+ var result = 0.0f; var value = -1.57079633f;
+
+ for (var iteration = 0; iteration < iterations; iteration++)
+ {
+ value += sinSingleDelta;
+ result += MathF.Sin(value);
+ }
+
+ var diff = MathF.Abs(sinSingleExpectedResult - result);
+
+ if (diff > singleEpsilon)
+ {
+ throw new Exception($"Expected Result {sinSingleExpectedResult,10:g9}; Actual Result {result,10:g9}");
+ }
+ }
+ }
+}
diff --git a/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/SinhSingle.cs b/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/SinhSingle.cs
new file mode 100644
index 0000000000..9ed01e4f55
--- /dev/null
+++ b/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/SinhSingle.cs
@@ -0,0 +1,47 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using Microsoft.Xunit.Performance;
+
+namespace Functions
+{
+ public static partial class MathTests
+ {
+ // Tests MathF.Sinh(float) over 5000 iterations for the domain -1, +1
+
+ private const float sinhSingleDelta = 0.0004f;
+ private const float sinhSingleExpectedResult = 1.26028216f;
+
+ [Benchmark]
+ public static void SinhSingleBenchmark()
+ {
+ foreach (var iteration in Benchmark.Iterations)
+ {
+ using (iteration.StartMeasurement())
+ {
+ SinhSingleTest();
+ }
+ }
+ }
+
+ public static void SinhSingleTest()
+ {
+ var result = 0.0f; var value = -1.0f;
+
+ for (var iteration = 0; iteration < iterations; iteration++)
+ {
+ value += sinhSingleDelta;
+ result += MathF.Sinh(value);
+ }
+
+ var diff = MathF.Abs(sinhSingleExpectedResult - result);
+
+ if (diff > singleEpsilon)
+ {
+ throw new Exception($"Expected Result {sinhSingleExpectedResult,10:g9}; Actual Result {result,10:g9}");
+ }
+ }
+ }
+}
diff --git a/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/SqrtSingle.cs b/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/SqrtSingle.cs
new file mode 100644
index 0000000000..f7349c1a5f
--- /dev/null
+++ b/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/SqrtSingle.cs
@@ -0,0 +1,47 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using Microsoft.Xunit.Performance;
+
+namespace Functions
+{
+ public static partial class MathTests
+ {
+ // Tests MathF.Sqrt(float) over 5000 iterations for the domain 0, PI
+
+ private const float sqrtSingleDelta = 0.000628318531f;
+ private const float sqrtSingleExpectedResult = 5909.03027f;
+
+ [Benchmark]
+ public static void SqrtSingleBenchmark()
+ {
+ foreach (var iteration in Benchmark.Iterations)
+ {
+ using (iteration.StartMeasurement())
+ {
+ SqrtSingleTest();
+ }
+ }
+ }
+
+ public static void SqrtSingleTest()
+ {
+ var result = 0.0f; var value = 0.0f;
+
+ for (var iteration = 0; iteration < iterations; iteration++)
+ {
+ value += sqrtSingleDelta;
+ result += MathF.Sqrt(value);
+ }
+
+ var diff = MathF.Abs(sqrtSingleExpectedResult - result);
+
+ if (diff > singleEpsilon)
+ {
+ throw new Exception($"Expected Result {sqrtSingleExpectedResult,10:g9}; Actual Result {result,10:g9}");
+ }
+ }
+ }
+}
diff --git a/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/TanSingle.cs b/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/TanSingle.cs
new file mode 100644
index 0000000000..b81050bfa3
--- /dev/null
+++ b/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/TanSingle.cs
@@ -0,0 +1,47 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using Microsoft.Xunit.Performance;
+
+namespace Functions
+{
+ public static partial class MathTests
+ {
+ // Tests MathF.Tan(float) over 5000 iterations for the domain -PI/2, +PI/2
+
+ private const float tanSingleDelta = 0.0004f;
+ private const float tanSingleExpectedResult = 1.66717815f;
+
+ [Benchmark]
+ public static void TanSingleBenchmark()
+ {
+ foreach (var iteration in Benchmark.Iterations)
+ {
+ using (iteration.StartMeasurement())
+ {
+ TanSingleTest();
+ }
+ }
+ }
+
+ public static void TanSingleTest()
+ {
+ var result = 0.0f; var value = -1.0f;
+
+ for (var iteration = 0; iteration < iterations; iteration++)
+ {
+ value += tanSingleDelta;
+ result += MathF.Tan(value);
+ }
+
+ var diff = MathF.Abs(tanSingleExpectedResult - result);
+
+ if (diff > singleEpsilon)
+ {
+ throw new Exception($"Expected Result {tanSingleExpectedResult,10:g9}; Actual Result {result,10:g9}");
+ }
+ }
+ }
+}
diff --git a/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/TanhSingle.cs b/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/TanhSingle.cs
new file mode 100644
index 0000000000..160e1135bf
--- /dev/null
+++ b/tests/src/JIT/Performance/CodeQuality/Math/Functions/Single/TanhSingle.cs
@@ -0,0 +1,47 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using Microsoft.Xunit.Performance;
+
+namespace Functions
+{
+ public static partial class MathTests
+ {
+ // Tests MathF.Tanh(float) over 5000 iterations for the domain -1, +1
+
+ private const float tanhSingleDelta = 0.0004f;
+ private const float tanhSingleExpectedResult = 0.816701353f;
+
+ [Benchmark]
+ public static void TanhSingleBenchmark()
+ {
+ foreach (var iteration in Benchmark.Iterations)
+ {
+ using (iteration.StartMeasurement())
+ {
+ TanhSingleTest();
+ }
+ }
+ }
+
+ public static void TanhSingleTest()
+ {
+ var result = 0.0f; var value = -1.0f;
+
+ for (var iteration = 0; iteration < iterations; iteration++)
+ {
+ value += tanhSingleDelta;
+ result += MathF.Tanh(value);
+ }
+
+ var diff = MathF.Abs(tanhSingleExpectedResult - result);
+
+ if (diff > singleEpsilon)
+ {
+ throw new Exception($"Expected Result {tanhSingleExpectedResult,10:g9}; Actual Result {result,10:g9}");
+ }
+ }
+ }
+}