add from giga-device, new branch added

This commit is contained in:
Nitload Youmu
2025-08-21 20:44:30 +08:00
parent 43bbc06bbb
commit fb9398e8be
135 changed files with 1505 additions and 1107 deletions
+30 -2
View File
@@ -64,9 +64,37 @@ namespace StgSharp
Console.WriteLine(
"=== HLSF (Hybrid Layer Segregated Fit Allocator) Test Arena ===\n");
HybridLayerSegregatedFitAllocator hlsfAllocator = new HybridLayerSegregatedFitAllocator(1024 * 1024);
hlsfAllocator.Alloc(1024 * 64);
Stack<HybridLayerSegregatedFitAllocationHandle> handles = [];
return;
hlsfAllocator.DisplayEntryLayout(false);
for (int c = 0; c < 1; c++)
{
int i = 0;
for (; i < 1024 * 1024 / 1024; i++)
{
Console.WriteLine($"{c} cycles: Allocating the {i}th block.");
handles.Push(hlsfAllocator.Alloc(1024));
hlsfAllocator.DisplayEntryLayout(true);
Console.ReadKey();
}
Console.WriteLine($"{i} allocs called, {handles.Count} handles collected.");
Console.ReadKey();
while (handles.TryPop(out HybridLayerSegregatedFitAllocationHandle h))
{
i--;
hlsfAllocator.Free(h);
Console.WriteLine($"{c} cycles: The {i}th handle is freed");
}
if (handles.Count != 0)
{
Console.WriteLine($"[警告] 第{c}轮后Stack未清空,剩余{handles.Count}个handle未释放!");
} else
{
Console.WriteLine("All handles freed.");
}
Console.ReadKey();
}
}
catch (Exception ex)
{