Files
Misaki.HighPerformance/Misaki.HighPerformance.Test/CollectionBenchmark.cs
Misaki 1e00f4eb25 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.
2025-04-03 15:47:43 +09:00

37 lines
729 B
C#

using BenchmarkDotNet.Attributes;
using Misaki.HighPerformance.Unsafe.Collections;
using Misaki.HighPerformance.Unsafe.Services;
namespace Misaki.HighPerformance.Test;
[MemoryDiagnoser]
public class CollectionBenchmark
{
[Params(10, 100, 1000)]
public int count = 100;
[GlobalSetup]
public void Setup()
{
AllocationManager.Initialize(512_000);
}
[Benchmark]
public void Array()
{
var array = new int[count];
}
[Benchmark]
public void UnsafeArray()
{
var array = new UnsafeArray<int>(count, Allocator.Temp);
AllocationManager.Reset();
}
[GlobalCleanup]
public void Cleanup()
{
AllocationManager.Dispose();
}
}