[Ryujinx.Tests.Memory] Address dotnet-format issues (#5390)
* dotnet format style --severity info Some changes were manually reverted. * dotnet format analyzers --serverity info Some changes have been minimally adapted. * Restore a few unused methods and variables * Silence dotnet format IDE0060 warnings * Address dotnet format CA1822 warnings * Address most dotnet format whitespace warnings * Apply dotnet format whitespace formatting A few of them have been manually reverted and the corresponding warning was silenced * Add comments to disabled warnings * Simplify properties and array initialization, Use const when possible, Remove trailing commas * Silence IDE0060 in .editorconfig * Revert "Simplify properties and array initialization, Use const when possible, Remove trailing commas" This reverts commit 9462e4136c0a2100dc28b20cf9542e06790aa67e. * dotnet format whitespace after rebase * Final dotnet format pass and fix naming rule violations * Apply suggestions from code review Co-authored-by: Ac_K <Acoustik666@gmail.com> * Remove unused constant --------- Co-authored-by: Ac_K <Acoustik666@gmail.com>
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user