Add benchmark method and improve Unsafe collections
Added a new benchmark method `For` in `ParallelNoiseBenchmark` to test gradient noise generation. Added demonstration code for `UnsafeArray` in `Program.cs` with a custom `Test` struct. Changed property accessors in `IUnsafeCollection<T>` to use `ref` returns for better memory efficiency. Changed property accessors and indexers in `UnsafeArray<T>`, `UnsafeList<T>`, and `UnsafeQueue<T>` to return `ref` types. Changed `TryDequeue` in `UnsafeQueue<T>` to return a default value instead of null. Changed `Clear` and `Dispose` methods in `UnsafeQueue<T>` to reset size and offset. Removed commented-out `BenchmarkRunner` code in `Program.cs`.
This commit is contained in:
@@ -3,11 +3,17 @@
|
||||
public unsafe interface IUnsafeCollection<T> : IDisposable
|
||||
where T : unmanaged
|
||||
{
|
||||
public T* Buffer { get; }
|
||||
public T* Buffer
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public int Size { get; }
|
||||
public int Size
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public T this[int index] { get; }
|
||||
public ref T this[int index] { get; }
|
||||
|
||||
public void Clear();
|
||||
public void ReAlloc(int newSize);
|
||||
|
||||
Reference in New Issue
Block a user