Update memory allocation practices and clean up code
Changed the `ParallelNoiseBenchmark` class to use `AllocationOption.None` for `UnsafeArray<float>` instances. Changed the `AllocationOption` enum to replace `UnInitialized` with `None` and clarified the `UnTracked` option. Changed constructors for `UnsafeArray<T>`, `UnsafeList<T>`, `UnsafeQueue<T>`, and `UnsafeStack<T>` to use `AllocationOption.None`. Changed the `HashMapHelper<TKey>` constructor to accept an `AllocationOption` parameter for improved flexibility. Changed the `Allocate` method documentation in `Arena.cs` to clarify memory management. Improved the `AllocationManager` class with a default arena size and updated allocation logic to handle new `AllocationOption` flags. Removed the import statement for `BenchmarkDotNet.Running` in `Program.cs` and added new imports for `Misaki.HighPerformance.Unsafe.Collections` and `Misaki.HighPerformance.Unsafe.Services`. Added a new `UnsafeArray<int>` in `Program.cs` and called `AllocationManager.Dispose()` to clean up resources.
This commit is contained in:
@@ -61,7 +61,7 @@ public class ParallelNoiseBenchmark
|
||||
[Benchmark]
|
||||
public static void JobSystem()
|
||||
{
|
||||
using var buffers = new UnsafeArray<float>(_LENGTH, Allocator.Persistent, AllocationOption.UnInitialized);
|
||||
using var buffers = new UnsafeArray<float>(_LENGTH, Allocator.Persistent, AllocationOption.None);
|
||||
var job = new NoiseJob()
|
||||
{
|
||||
buffers = buffers,
|
||||
@@ -76,7 +76,7 @@ public class ParallelNoiseBenchmark
|
||||
[Benchmark]
|
||||
public static void ParallelFor()
|
||||
{
|
||||
using var buffers = new UnsafeArray<float>(_LENGTH, Allocator.Persistent, AllocationOption.UnInitialized);
|
||||
using var buffers = new UnsafeArray<float>(_LENGTH, Allocator.Persistent, AllocationOption.None);
|
||||
|
||||
Parallel.For(0, _LENGTH, i =>
|
||||
{
|
||||
@@ -90,7 +90,7 @@ public class ParallelNoiseBenchmark
|
||||
[Benchmark]
|
||||
public static void For()
|
||||
{
|
||||
using var buffers = new UnsafeArray<float>(_LENGTH, Allocator.Persistent, AllocationOption.UnInitialized);
|
||||
using var buffers = new UnsafeArray<float>(_LENGTH, Allocator.Persistent, AllocationOption.None);
|
||||
for (var i = 0; i < _LENGTH; i++)
|
||||
{
|
||||
var x = i % _WIDTH;
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
using BenchmarkDotNet.Running;
|
||||
using Misaki.HighPerformance.Test;
|
||||
using Misaki.HighPerformance.Unsafe.Collections;
|
||||
using Misaki.HighPerformance.Unsafe.Services;
|
||||
|
||||
BenchmarkRunner.Run<CollectionBenchmark>();
|
||||
var unfreeArray = new UnsafeArray<int>(10, Allocator.Persistent);
|
||||
unfreeArray.Dispose();
|
||||
|
||||
AllocationManager.Dispose();
|
||||
|
||||
Reference in New Issue
Block a user