Using new file structure. Use new regexir display method. Fix line dependency error in prefix analysing.

Signed-off-by: Nitload <YoumuLiu_NSI@whv0t.onmicrosoft.com>
This commit is contained in:
Nitload
2026-07-12 02:04:57 +08:00
parent ae8a09efc2
commit b6cd2fc256
476 changed files with 16440 additions and 502 deletions
+62
View File
@@ -0,0 +1,62 @@
// -----------------------------------------------------------------------------
// file="SlabStressTest"
// Project: StgSharp
// Copyright (c) Nitload.
// SPDX-License-Identifier: MIT
// -----------------------------------------------------------------------------
using StgSharp.HighPerformance.Memory;
using System;
using System.Diagnostics;
namespace StgSharp
{
internal static class SlabStressTest
{
// Exercise the Nonconcurrent Chunked SLAB used by HLSF (allocation/free only)
public static unsafe void Run()
{
Console.WriteLine("=== SLAB Allocator (Chunked) Single-Thread Stress Test ===");
// Use SLAB with element size of pointer (nuint) to simulate Entry handles
SlabAllocator<BunchOfBytes> slab = SlabAllocator.Create<BunchOfBytes>(64, SlabBufferLayout.Chunked, false);
int cycles = 10;
int allocsPerCycle = 200_000; // large enough to force internal growth
Stopwatch sw = new Stopwatch();
for (int c = 0; c < cycles; c++)
{
Console.WriteLine($"--- Cycle {c+1} ---");
nuint[] ptrs = new nuint[allocsPerCycle];
sw.Restart();
for (int i = 0; i < allocsPerCycle; i++) {
ptrs[i] = slab.Allocate();
}
sw.Stop();
Console.WriteLine($"Allocate: {allocsPerCycle} in {sw.Elapsed.TotalSeconds:0.00}s");
sw.Restart();
for (int i = 0; i < allocsPerCycle; i++) {
slab.Free(ptrs[i]);
}
sw.Stop();
Console.WriteLine($"Free: {allocsPerCycle} in {sw.Elapsed.TotalSeconds:0.00}s");
}
slab.Dispose();
Console.WriteLine("=== SLAB Stress Complete ===");
}
internal unsafe struct BunchOfBytes
{
public fixed byte Data[128];
}
}
}