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.
37 lines
729 B
C#
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();
|
|
}
|
|
} |