Enhance memory management and data structures
Updated `CollectionBenchmark` for setup/cleanup methods, streamlined benchmarking in `Program.cs`, and improved documentation in `AllocationOption` and `Allocator` enums. Made `Enumerator` structs public in several collections and clarified constructor parameters. Introduced a new `UnsafeStack` struct for stack operations. Enhanced `AllocationManager` with better memory tracking and management, ensuring proper allocation and disposal.
This commit is contained in:
@@ -10,32 +10,28 @@ public class CollectionBenchmark
|
||||
[Params(10, 100, 1000)]
|
||||
public int count = 100;
|
||||
|
||||
[GlobalSetup]
|
||||
public void Setup()
|
||||
{
|
||||
AllocationManager.Initialize(512_000);
|
||||
}
|
||||
|
||||
[Benchmark]
|
||||
public void Array()
|
||||
{
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
var array = new int[count];
|
||||
}
|
||||
var array = new int[count];
|
||||
}
|
||||
|
||||
[Benchmark]
|
||||
public void UnsafeArray()
|
||||
{
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
var array = new UnsafeArray<int>(count, Allocator.Temp);
|
||||
for (var j = 0; j < count; j++)
|
||||
{
|
||||
array[j] = j;
|
||||
}
|
||||
var array = new UnsafeArray<int>(count, Allocator.Temp);
|
||||
AllocationManager.Reset();
|
||||
}
|
||||
|
||||
foreach (var item in array)
|
||||
{
|
||||
Console.WriteLine(item);
|
||||
}
|
||||
|
||||
AllocationManager.Reset();
|
||||
}
|
||||
[GlobalCleanup]
|
||||
public void Cleanup()
|
||||
{
|
||||
AllocationManager.Dispose();
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,4 @@
|
||||
using Misaki.HighPerformance.Test;
|
||||
using Misaki.HighPerformance.Unsafe.Services;
|
||||
using BenchmarkDotNet.Running;
|
||||
using Misaki.HighPerformance.Test;
|
||||
|
||||
AllocationManager.Initialize(512_000);
|
||||
var test = new CollectionBenchmark();
|
||||
test.UnsafeArray();
|
||||
AllocationManager.Dispose();
|
||||
BenchmarkRunner.Run<CollectionBenchmark>();
|
||||
|
||||
Reference in New Issue
Block a user