From db897c51bfee6ce8c3e28f6e194f129832e22c7b Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Wed, 29 Jul 2020 19:17:02 +0200 Subject: [PATCH] Added a performance test --- ExaArrayTests/ExaArray1DTests.cs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/ExaArrayTests/ExaArray1DTests.cs b/ExaArrayTests/ExaArray1DTests.cs index 49eb862..7eb9412 100644 --- a/ExaArrayTests/ExaArray1DTests.cs +++ b/ExaArrayTests/ExaArray1DTests.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Threading.Tasks; @@ -91,6 +92,35 @@ namespace ExaArrayTests exaA.Extend(5_000_000_000); Assert.That(exaA.Length, Is.EqualTo(5_000_000_000)); } + + [Test] + public void TestPerformance01() + { + var exaMaxElements = new ExaArray1D(Strategy.MAX_ELEMENTS); + exaMaxElements.Extend(5_000_000_000); + + var t1 = new Stopwatch(); + t1.Start(); + + for (ulong n = 0; n < 100_000_000; n++) + exaMaxElements[n] = 0x55; + t1.Stop(); + + TestContext.WriteLine($"Performing 100M assignments took {t1.ElapsedMilliseconds} ms by means of the max. elements strategy."); + exaMaxElements = null; + + var exaMaxPerformance = new ExaArray1D(Strategy.MAX_PERFORMANCE); + exaMaxPerformance.Extend(5_000_000_000); + + var t2 = new Stopwatch(); + t2.Start(); + + for (ulong n = 0; n < 100_000_000; n++) + exaMaxPerformance[n] = 0x55; + t2.Stop(); + + TestContext.WriteLine($"Performing 100M assignments took {t2.ElapsedMilliseconds} ms by means of the max. performance strategy."); + } } } } \ No newline at end of file