using System.Reflection; using BenchmarkDotNet.Attributes; using Collections.Pooled; using Recyclable.Collections.Benchmarks.Core; namespace Recyclable.Collections.Benchmarks.POC { [MemoryDiagnoser] public partial class RecyclableLongListPocBenchmarks : PocBenchmarkBase { private long[]? _testArray; public long[] TestObjects => _testArray ?? throw new NullReferenceException("Something is wrong and test objects are null"); public RecyclableLongList TestObjectsAsRecyclableLongList => _testRecyclableLongList ?? throw new NullReferenceException($"Something is wrong and {nameof(RecyclableLongList)} is null"); private RecyclableLongList? _testRecyclableLongList; private PooledList? _testPooledList; internal PooledList TestPooledList => _testPooledList ?? throw new NullReferenceException($"Something is wrong and {nameof(PooledList)} is null"); private static readonly MethodInfo _ensureCapacityNewFunc; static RecyclableLongListPocBenchmarks() { _ensureCapacityNewFunc = typeof(RecyclableLongList).GetMethod("EnsureCapacity", BindingFlags.Static | BindingFlags.NonPublic) ?? throw new NullReferenceException($"Method EnsureCapacity not found in class {nameof(RecyclableLongList)}"); } public override void Setup() { Console.WriteLine("******* SETTING UP EXPECTED RESULTS DATA *******"); _testArray = DataGenerator.EnumerateTestObjects(TestObjectCount); base.Setup(); } public override void Cleanup() { _testArray = null; _testRecyclableLongList?.Dispose(); _testRecyclableLongList = null; _testPooledList?.Dispose(); _testPooledList = null; base.Cleanup(); } } }