This commit renames `AllocationType` to `AllocationOption` across multiple files, enhancing clarity in memory allocation practices. Key updates include: - Modifications to the `UnsafeArray`, `ParallelNoiseBenchmark`, `Arena`, and `DynamicArena` classes to utilize the new `AllocationOption`. - Refactoring of the `AllocationManager` and `HashMapHelper` classes to support the new allocation strategy. - Removal of the `Misaki.HighPerformance.Mathematics` project reference, indicating a restructuring of dependencies. - Introduction of a new `MathUtilities` class for calculating the smallest power of two, aiding memory allocation strategies. These changes collectively improve code maintainability and clarity in memory management.
41 lines
876 B
C#
41 lines
876 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;
|
|
|
|
[Benchmark]
|
|
public void Array()
|
|
{
|
|
for (var i = 0; i < count; i++)
|
|
{
|
|
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;
|
|
}
|
|
|
|
foreach (var item in array)
|
|
{
|
|
Console.WriteLine(item);
|
|
}
|
|
|
|
AllocationManager.Reset();
|
|
}
|
|
}
|
|
} |