Merge branch 'main' of https://github.com/mlemanczyk/Recyclable.Collections
This commit is contained in:
commit
9895347630
13 files changed
+73
-17
No files matched your search
@@ -17,7 +17,7 @@ namespace Recyclable.Collections.Benchmarks
|
|||||||
public RecyclableCollectionsBenchmarks() : base()
|
public RecyclableCollectionsBenchmarks() : base()
|
||||||
{
|
{
|
||||||
TestObjectCount = 1;
|
TestObjectCount = 1;
|
||||||
BaselineBenchmarkType = RecyclableCollectionsBenchmarkSource.PooledList;
|
BaselineBenchmarkType = RecyclableCollectionsBenchmarkSource.List;
|
||||||
BenchmarkType = RecyclableCollectionsBenchmarkSource.RecyclableLongList;
|
BenchmarkType = RecyclableCollectionsBenchmarkSource.RecyclableLongList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ namespace Recyclable.Collections.Benchmarks
|
|||||||
|
|
||||||
[Params
|
[Params
|
||||||
(
|
(
|
||||||
RecyclableCollectionsBenchmarkSource.PooledList
|
RecyclableCollectionsBenchmarkSource.List
|
||||||
)]
|
)]
|
||||||
public override RecyclableCollectionsBenchmarkSource BaselineBenchmarkType { get => base.BaselineBenchmarkType; set => base.BaselineBenchmarkType = value; }
|
public override RecyclableCollectionsBenchmarkSource BaselineBenchmarkType { get => base.BaselineBenchmarkType; set => base.BaselineBenchmarkType = value; }
|
||||||
|
|
||||||
|
|||||||
@@ -25,11 +25,31 @@ public static class Program
|
|||||||
//var benchmark = new RecyclableCollectionsBenchmarks();
|
//var benchmark = new RecyclableCollectionsBenchmarks();
|
||||||
//benchmark.Setup();
|
//benchmark.Setup();
|
||||||
|
|
||||||
|
static void RunAssemblyBenchmarks()
|
||||||
|
{
|
||||||
|
_ = BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(new[] { "-f*" });
|
||||||
|
}
|
||||||
|
|
||||||
|
static void RunRecyclableCollectionsBenchmarks()
|
||||||
|
{
|
||||||
|
_ = BenchmarkRunner.Run<RecyclableCollectionsBenchmarks>(BenchmarkConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void RunSelectedBenchmarks()
|
||||||
|
{
|
||||||
|
// ****************
|
||||||
|
// *** Template ***
|
||||||
|
// ****************
|
||||||
|
var benchmark = new RecyclableCollectionsBenchmarks();
|
||||||
|
benchmark.Setup();
|
||||||
|
benchmark.RecyclableLongList_IndexOf_BestAndWorstCases();
|
||||||
|
benchmark.Cleanup();
|
||||||
|
|
||||||
//foreach (var _ in Enumerable.Range(1, 1000))
|
//foreach (var _ in Enumerable.Range(1, 1000))
|
||||||
//{
|
//{
|
||||||
//benchmark.RecyclableLongList_Remove_FirstItems();
|
// benchmark.RecyclableLongList_Remove_FirstItems();
|
||||||
//benchmark.RecyclableLongList_RemoveAt_LastItems();
|
// benchmark.RecyclableLongList_RemoveAt_LastItems();
|
||||||
//benchmark.List_RemoveAt_LastItems();
|
// benchmark.List_RemoveAt_LastItems();
|
||||||
//}
|
//}
|
||||||
|
|
||||||
//benchmark.Cleanup();
|
//benchmark.Cleanup();
|
||||||
@@ -46,7 +66,7 @@ public static class Program
|
|||||||
_ = BenchmarkRunner.Run<WhenParallelSearchBenchmarks>(BenchmarkConfig);
|
_ = BenchmarkRunner.Run<WhenParallelSearchBenchmarks>(BenchmarkConfig);
|
||||||
_ = BenchmarkRunner.Run<RoundBenchmarks>(BenchmarkConfig);
|
_ = BenchmarkRunner.Run<RoundBenchmarks>(BenchmarkConfig);
|
||||||
_ = BenchmarkRunner.Run<SpanVsArrayBenchmarks>(BenchmarkConfig);
|
_ = BenchmarkRunner.Run<SpanVsArrayBenchmarks>(BenchmarkConfig);
|
||||||
//ArraySizeLimitPocBenchmarks>(BenchmarkConfig);
|
// ArraySizeLimitPocBenchmarks>(BenchmarkConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
@@ -54,6 +74,7 @@ public static class Program
|
|||||||
RunRecyclableCollectionsBenchmarks();
|
RunRecyclableCollectionsBenchmarks();
|
||||||
// RunPocBenchmarks();
|
// RunPocBenchmarks();
|
||||||
// RunSelectedBenchmarks();
|
// RunSelectedBenchmarks();
|
||||||
//RunAssemblyBenchmarks();
|
// RunAssemblyBenchmarks();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
namespace Recyclable.Collections
|
namespace Recyclable.Collections
|
||||||
{
|
{
|
||||||
public interface IRandomNumberGenerator
|
internal interface IRandomNumberGenerator
|
||||||
{
|
{
|
||||||
int NextInt32(int startIndex, int endIndex);
|
int NextInt32(int startIndex, int endIndex);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
namespace Recyclable.Collections
|
namespace Recyclable.Collections
|
||||||
{
|
{
|
||||||
public interface IRecyclableOwner<T> : IList<T>
|
internal interface IRecyclableOwner<T> : IList<T>
|
||||||
{
|
{
|
||||||
T this[long index] { get; set; }
|
T this[long index] { get; set; }
|
||||||
int BlockSize { get; }
|
int BlockSize { get; }
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ namespace Recyclable.Collections
|
|||||||
{
|
{
|
||||||
// The source code was taken from https://codereview.stackexchange.com/questions/205407/quicksort-without-recursion.
|
// The source code was taken from https://codereview.stackexchange.com/questions/205407/quicksort-without-recursion.
|
||||||
// It was only beautified for .Net 6.0+.
|
// It was only beautified for .Net 6.0+.
|
||||||
public static class ListExtensions
|
internal static class ListExtensions
|
||||||
{
|
{
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static bool Contains<T>(this RecyclableList<T[]> arrays, T item) => arrays.Any(x => x.Contains(item));
|
public static bool Contains<T>(this RecyclableList<T[]> arrays, T item) => arrays.Any(x => x.Contains(item));
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ using System.Runtime.CompilerServices;
|
|||||||
|
|
||||||
namespace Recyclable.Collections
|
namespace Recyclable.Collections
|
||||||
{
|
{
|
||||||
public static class MathUtils
|
internal static class MathUtils
|
||||||
{
|
{
|
||||||
// private static readonly long[] Pow2 = new long[]
|
// private static readonly long[] Pow2 = new long[]
|
||||||
// {
|
// {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
namespace Recyclable.Collections
|
namespace Recyclable.Collections
|
||||||
{
|
{
|
||||||
public class MemoryBucket<T>
|
internal class MemoryBucket<T>
|
||||||
{
|
{
|
||||||
public MemoryBucket(T[] memory, MemoryBucket<T> nextBucket)
|
public MemoryBucket(T[] memory, MemoryBucket<T> nextBucket)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
<PackageId>Recyclable.Collections</PackageId>
|
<PackageId>Recyclable.Collections</PackageId>
|
||||||
<PackageVersion>0.0.3.1-alpha</PackageVersion>
|
<PackageVersion>0.0.3.2-alpha</PackageVersion>
|
||||||
<Authors>Marek Lemańczyk</Authors>
|
<Authors>Marek Lemańczyk</Authors>
|
||||||
<Company>N/A</Company>
|
<Company>N/A</Company>
|
||||||
<Product>Recyclable.Collections</Product>
|
<Product>Recyclable.Collections</Product>
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
<PackageLicenseFile>LICENSE.md</PackageLicenseFile>
|
<PackageLicenseFile>LICENSE.md</PackageLicenseFile>
|
||||||
<PackageReadmeFile>README.md</PackageReadmeFile>
|
<PackageReadmeFile>README.md</PackageReadmeFile>
|
||||||
<RepositoryType>git</RepositoryType>
|
<RepositoryType>git</RepositoryType>
|
||||||
<PackageReleaseNotes>`RecyclableList<T>` and `RecyclableLongList<T>` implemented. NuGet packages updated.</PackageReleaseNotes>
|
<PackageReleaseNotes>Several classes made internal to avoid conflicts with other packages. Not ready classes made internal for now.</PackageReleaseNotes>
|
||||||
<Platforms>AnyCPU;x64</Platforms>
|
<Platforms>AnyCPU;x64</Platforms>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ using System.Runtime.CompilerServices;
|
|||||||
|
|
||||||
namespace Recyclable.Collections
|
namespace Recyclable.Collections
|
||||||
{
|
{
|
||||||
public static class RecyclableLongListExtensions
|
internal static class RecyclableLongListExtensions
|
||||||
{
|
{
|
||||||
private const int _minPooledArraySize = RecyclableDefaults.MinPooledArrayLength;
|
private const int _minPooledArraySize = RecyclableDefaults.MinPooledArrayLength;
|
||||||
private const long ItemNotFoundIndexLong = -1L;
|
private const long ItemNotFoundIndexLong = -1L;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
namespace Recyclable.Collections
|
namespace Recyclable.Collections
|
||||||
{
|
{
|
||||||
public readonly struct SearchConfiguration<TList, TItem>
|
internal readonly struct SearchConfiguration<TList, TItem>
|
||||||
{
|
{
|
||||||
public TItem ItemToFind { get; init; }
|
public TItem ItemToFind { get; init; }
|
||||||
public TList List { get; init; }
|
public TList List { get; init; }
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
namespace Recyclable.Collections
|
namespace Recyclable.Collections
|
||||||
{
|
{
|
||||||
public class SystemRandomNumberGenerator : IRandomNumberGenerator
|
internal class SystemRandomNumberGenerator : IRandomNumberGenerator
|
||||||
{
|
{
|
||||||
private readonly Random _random = new();
|
private readonly Random _random = new();
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
using Microsoft.CodeAnalysis;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace SourceCodeGenerator.Net
|
||||||
|
{
|
||||||
|
[Generator]
|
||||||
|
public class RecyclableCollectionsGenerator : ISourceGenerator
|
||||||
|
{
|
||||||
|
public void Execute(GeneratorExecutionContext context)
|
||||||
|
{
|
||||||
|
context.AddSource($".g.cs");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Initialize(GeneratorInitializationContext context)
|
||||||
|
{
|
||||||
|
// Nothing to initialize at this point yet
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>netstandard2.0</TargetFramework>
|
||||||
|
<EnforceExtendedAnalyzerRules>True</EnforceExtendedAnalyzerRules>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.6.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
Reference in new issue
Block a user