Skip to content

Commit

Permalink
memcpy test #2
Browse files Browse the repository at this point in the history
  • Loading branch information
CptMoore committed Jan 15, 2025
1 parent 78b138d commit b49ed64
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions ModTek/Features/Logging/FastBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -497,23 +497,29 @@ private struct My128Bit
private static long CalcMemcpyTicks(Memcpy memcpy)
{
const int MaxSize = 512 * 1024 - 1;
var src = stackalloc byte[MaxSize];
var dst = stackalloc byte[MaxSize];
var srcA = new byte[MaxSize];
var dstA = new byte[MaxSize];

const int TestRunsPerSize = 100;
var memCpyTicks = new long[TestRunsPerSize];

const int WarmupCount = 1000;
for (var w = 0; w < WarmupCount + 1; w++)
fixed (byte* src = srcA)
{
var shouldMeasure = w == WarmupCount;
for (var run = 0; run < TestRunsPerSize; run++)
fixed (byte* dst = dstA)
{
var start = shouldMeasure ? MTStopwatch.GetTimestamp() : 0;
memcpy(dst, src, MaxSize);
if (shouldMeasure)
for (var w = 0; w < WarmupCount + 1; w++)
{
memCpyTicks[run] = MTStopwatch.GetTimestamp() - start;
var shouldMeasure = w == WarmupCount;
for (var run = 0; run < TestRunsPerSize; run++)
{
var start = shouldMeasure ? MTStopwatch.GetTimestamp() : 0;
memcpy(dst, src, MaxSize);
if (shouldMeasure)
{
memCpyTicks[run] = MTStopwatch.GetTimestamp() - start;
}
}
}
}
}
Expand Down

0 comments on commit b49ed64

Please sign in to comment.