diff options
Diffstat (limited to 'src/Ryujinx.Tests.Memory/TrackingTests.cs')
| -rw-r--r-- | src/Ryujinx.Tests.Memory/TrackingTests.cs | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/src/Ryujinx.Tests.Memory/TrackingTests.cs b/src/Ryujinx.Tests.Memory/TrackingTests.cs index faf29557..dce73cf4 100644 --- a/src/Ryujinx.Tests.Memory/TrackingTests.cs +++ b/src/Ryujinx.Tests.Memory/TrackingTests.cs @@ -102,15 +102,17 @@ namespace Ryujinx.Tests.Memory allHandle.Reprotect(); (ulong address, ulong size)? readTrackingTriggeredAll = null; - Action registerReadAction = () => + + void RegisterReadAction() { readTrackingTriggeredAll = null; allHandle.RegisterAction((address, size) => { readTrackingTriggeredAll = (address, size); }); - }; - registerReadAction(); + } + + RegisterReadAction(); // Create 16 page sized handles contained within the allHandle. RegionHandle[] containedHandles = new RegionHandle[16]; @@ -149,7 +151,7 @@ namespace Ryujinx.Tests.Memory } // Clear flags and reset read action. - registerReadAction(); + RegisterReadAction(); allHandle.Reprotect(); containedHandles[i].Reprotect(); } @@ -157,8 +159,8 @@ namespace Ryujinx.Tests.Memory [Test] public void PageAlignment( - [Values(1ul, 512ul, 2048ul, 4096ul, 65536ul)] [Random(1ul, 65536ul, RndCnt)] ulong address, - [Values(1ul, 4ul, 1024ul, 4096ul, 65536ul)] [Random(1ul, 65536ul, RndCnt)] ulong size) + [Values(1ul, 512ul, 2048ul, 4096ul, 65536ul)][Random(1ul, 65536ul, RndCnt)] ulong address, + [Values(1ul, 4ul, 1024ul, 4096ul, 65536ul)][Random(1ul, 65536ul, RndCnt)] ulong size) { ulong alignedStart = (address / PageSize) * PageSize; ulong alignedEnd = ((address + size + PageSize - 1) / PageSize) * PageSize; @@ -204,7 +206,7 @@ namespace Ryujinx.Tests.Memory long finishedTime = 0; RegionHandle[] handles = new RegionHandle[threadCount * handlesPerThread]; - Random globalRand = new Random(); + Random globalRand = new(); for (int i = 0; i < handles.Length; i++) { @@ -212,7 +214,7 @@ namespace Ryujinx.Tests.Memory handles[i].Reprotect(); } - List<Thread> testThreads = new List<Thread>(); + List<Thread> testThreads = new(); // Dirty flag consumer threads int dirtyFlagReprotects = 0; @@ -224,7 +226,7 @@ namespace Ryujinx.Tests.Memory int handleBase = randSeed * handlesPerThread; while (Stopwatch.GetTimestamp() < finishedTime) { - Random random = new Random(randSeed); + Random random = new(randSeed); RegionHandle handle = handles[handleBase + random.Next(handlesPerThread)]; if (handle.Dirty) @@ -243,7 +245,7 @@ namespace Ryujinx.Tests.Memory int randSeed = i; testThreads.Add(new Thread(() => { - Random random = new Random(randSeed); + Random random = new(randSeed); ulong handleBase = (ulong)(randSeed * handlesPerThread * PageSize); while (Stopwatch.GetTimestamp() < finishedTime) { @@ -261,7 +263,7 @@ namespace Ryujinx.Tests.Memory testThreads.Add(new Thread(() => { int maxAddress = threadCount * handlesPerThread * PageSize; - Random random = new Random(randSeed + 512); + Random random = new(randSeed + 512); while (Stopwatch.GetTimestamp() < finishedTime) { RegionHandle handle = _tracking.BeginTracking((ulong)random.Next(maxAddress), (ulong)random.Next(65536), 0); @@ -303,7 +305,7 @@ namespace Ryujinx.Tests.Memory int signalThreadsDone = 0; bool isRegistered = false; - Action registerReadAction = () => + void RegisterReadAction() { registeredCount++; handle.RegisterAction((address, size) => @@ -311,7 +313,7 @@ namespace Ryujinx.Tests.Memory isRegistered = false; Interlocked.Increment(ref triggeredCount); }); - }; + } const int threadCount = 16; const int iterationCount = 10000; @@ -322,7 +324,7 @@ namespace Ryujinx.Tests.Memory int randSeed = i; signalThreads[i] = new Thread(() => { - Random random = new Random(randSeed); + Random random = new(randSeed); for (int j = 0; j < iterationCount; j++) { _tracking.VirtualMemoryEvent((ulong)random.Next(PageSize), 4, false); @@ -346,7 +348,7 @@ namespace Ryujinx.Tests.Memory if (!isRegistered) { isRegistered = true; - registerReadAction(); + RegisterReadAction(); } } |
