Refactor unsafe collections and benchmarks
Changed the `CollectionBenchmark` class to use unsafe code for improved memory operations and added benchmarks for stack-allocated arrays. Changed the `ParallelNoiseBenchmark` class to remove the internal `NoiseJob` struct, promoting better organization. Changed the `AllocationManager` class to remove the lock mechanism for thread safety and simplified the `Reset` method. Changed the `Arena` and `DynamicArena` structs to include `Initialize` methods for better initialization control. Changed the `UnsafeArray<T>`, `UnsafeHashSet<T>`, and `UnsafeList<T>` structs to improve element access and management. Updated the `UnsafeCollectionExtensions` class to enhance usability with new methods for copying and converting collections. Updated the `MemoryLeakException` class to provide more detailed stack trace information for better debugging. Removed the usage of `UnsafeHashMap` in `Program.cs` and directly ran the `CollectionBenchmark`. Added a new `NoiseJob` struct in `NoiseJob.cs` for generating gradient noise using `UnsafeArray<float>`. Fixed minor typos and improved method signatures throughout the codebase for clarity.
This commit is contained in:
@@ -1,10 +1,4 @@
|
||||
using Misaki.HighPerformance.Unsafe.Collections;
|
||||
using Misaki.HighPerformance.Unsafe.Helpers;
|
||||
using System.Numerics;
|
||||
using BenchmarkDotNet.Running;
|
||||
using Misaki.HighPerformance.Test;
|
||||
|
||||
unsafe
|
||||
{
|
||||
Console.WriteLine(sizeof(UnsafeHashMap<int, float>));
|
||||
Console.WriteLine(MemoryUtilities.AlignOf<UnsafeHashMap<int, float>>());
|
||||
Console.WriteLine(1 << Math.Min(3, BitOperations.TrailingZeroCount(sizeof(UnsafeHashMap<int, float>))));
|
||||
}
|
||||
BenchmarkRunner.Run<CollectionBenchmark>();
|
||||
|
||||
Reference in New Issue
Block a user