Some checks failed
Publish NuGet Packages / publish (pull_request) Failing after 1m5s
- Updated `.gitignore` to include `.vscode/` and clarified comments. - Introduced `SafeHandle` for managing memory alignment and safe access. - Refactored `UnsafeArray<T>` to add bounds checking and alignment logic. - Added `IUnsafeHashCollection<T>` for specialized hash-based collections. - Refactored `UnsafeHashMap<TKey, TValue>` and `UnsafeHashSet<T>` to use `HashMapHelper<TKey>` with alignment support. - Made `UnsafeSlotMap<T>` methods `readonly` for immutability. - Enhanced `HashMapHelper<TKey>` with alignment-aware buffer management and validation. - Updated benchmarks to use `UnsafeArray<Vector256<int>>` and added capacity checks. - Incremented assembly version to `1.1.3` in `Misaki.HighPerformance.LowLevel.csproj`. - Updated `Program.cs` to run `CollectionBenchmark` and demonstrate safe disposal handling.
54 lines
1.5 KiB
C#
54 lines
1.5 KiB
C#
//var threadCount = 8;
|
|
//var map = new ConcurrentSlotMap<int>();
|
|
|
|
//var barrier = new Barrier(threadCount);
|
|
|
|
//Parallel.For(0, threadCount, threadIndex =>
|
|
//{
|
|
// barrier.SignalAndWait();
|
|
// for (var i = 0; i < 1000; i++)
|
|
// {
|
|
// var id = map.Add(i + threadIndex * 1000, out var gen);
|
|
// if (i % 100 == 0)
|
|
// {
|
|
// map.Remove(id, gen);
|
|
// }
|
|
// }
|
|
//});
|
|
|
|
//Console.WriteLine($"Count should be {threadCount * 990}, actual: {map.Count}");
|
|
|
|
BenchmarkDotNet.Running.BenchmarkRunner.Run<Misaki.HighPerformance.Test.Benchmark.CollectionBenchmark>();
|
|
|
|
//using Misaki.HighPerformance.LowLevel.Buffer;
|
|
//using Misaki.HighPerformance.LowLevel.Collections;
|
|
//using Misaki.HighPerformance.LowLevel.Utilities;
|
|
|
|
//using (AllocationManager.CreateStackScope())
|
|
//{
|
|
// var array = new UnsafeArray<int>(10, Allocator.Stack);
|
|
// for (var i = 0; i < array.Count; i++)
|
|
// {
|
|
// array[i] = i;
|
|
// }
|
|
|
|
// foreach (var item in array.AsSpan())
|
|
// {
|
|
// Console.WriteLine(item);
|
|
// }
|
|
//}
|
|
|
|
//var arr1 = new Misaki.HighPerformance.LowLevel.Collections.UnsafeArray<int>(10, Misaki.HighPerformance.LowLevel.Buffer.Allocator.Persistent);
|
|
//var arr2 = arr1;
|
|
|
|
//arr1.Dispose();
|
|
//try
|
|
//{
|
|
// arr2[0] = 42; // This should throw an exception because arr1 has been disposed.
|
|
//}
|
|
//catch (Exception ex)
|
|
//{
|
|
// Console.WriteLine($"Caught expected exception: {ex.Message}");
|
|
//}
|
|
//arr2.Dispose(); // This should not cause a double free error because of safe handle.
|