Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NetFabric/NetFabric.Hyperlinq
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: main
Choose a base ref
...
head repository: manofstick/NetFabric.Hyperlinq
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
  • 6 commits
  • 7 files changed
  • 1 contributor

Commits on Nov 6, 2020

  1. Copy the full SHA
    fab14e3 View commit details
  2. Copy the full SHA
    02e6e94 View commit details
  3. Copy the full SHA
    326dad1 View commit details
  4. Copy the full SHA
    b246657 View commit details
  5. Copy the full SHA
    8c46787 View commit details

Commits on Nov 7, 2020

  1. Copy the full SHA
    fc8d70f View commit details
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
#if !(NETCOREAPP2_1 || NET48)

using BenchmarkDotNet.Attributes;
using Cistern.ValueLinq;
using System;

namespace NetFabric.Hyperlinq.Benchmarks
{
public partial class AllBenchmarks : RandomBenchmarksBase
{
[BenchmarkCategory("Array")]
[Benchmark]
public bool CisternValueLinq_Array() =>
array
.OfArray() // *shouldn't* need this!!! only because we are in the NetFabric.Hyperlinq namespace; so c# chooses incorrect overload
.All(_ => true);

[BenchmarkCategory("Array")]
[Benchmark]
public bool CisternValueLinq_Span() =>
Enumerable
.FromSpan<int[], int>(array, array => array.AsSpan())
.All(_ => true);

[BenchmarkCategory("Array")]
[Benchmark]
public bool CisternValueLinq_Memory() =>
memory
.OfMemory() // *shouldn't* need this!!! only because we are in the NetFabric.Hyperlinq namespace; so c# chooses incorrect overload
.All(_ => true);

[BenchmarkCategory("Enumerable_Value")]
[Benchmark]
public bool CisternValueLinq_Enumerable_Value() =>
enumerableValue
.OfEnumeratorConstraint<int, TestEnumerable.Enumerable, TestEnumerable.Enumerable.Enumerator>(x => x.GetEnumerator())
.All(_ => true);

[BenchmarkCategory("Collection_Value")]
[Benchmark]
public bool CisternValueLinq_Collection_Value() =>
collectionValue
.OfEnumeratorConstraint<int, TestCollection.Enumerable, TestCollection.Enumerable.Enumerator>(x => x.GetEnumerator(), collectionValue.Count)
.All(_ => true);

[BenchmarkCategory("List_Value")]
[Benchmark]
public bool CisternValueLinq_List_Value() =>
listValue
.OfReadOnlyListConstraint<int, TestList.Enumerable>()
.All(_ => true);

[BenchmarkCategory("Enumerable_Reference")]
[Benchmark]
public bool CisternValueLinq_Enumerable_Reference() =>
enumerableReference
.OfEnumerable() // *shouldn't* need this!!! only because we are in the NetFabric.Hyperlinq namespace; so c# chooses incorrect overload
.All(_ => true);

[BenchmarkCategory("Collection_Reference")]
[Benchmark]
public bool CisternValueLinq_Collection_Reference() =>
collectionReference
.OfEnumerable() // *shouldn't* need this!!! only because we are in the NetFabric.Hyperlinq namespace; so c# chooses incorrect overload
.All(_ => true);

[BenchmarkCategory("List_Reference")]
[Benchmark]
public bool CisternValueLinq_List_Reference() =>
listReference
.OfEnumerable() // *shouldn't* need this!!! only because we are in the NetFabric.Hyperlinq namespace; so c# chooses incorrect overload
.All(_ => true);

// ----

struct AlwaysTrue: IFunc<int, bool> { public bool Invoke(int _) => true; }

[BenchmarkCategory("Array")]
[Benchmark]
public bool CisternValueLinq_ValueLambda_Array() =>
array
.OfArray() // *shouldn't* need this!!! only because we are in the NetFabric.Hyperlinq namespace; so c# chooses incorrect overload
.All(new AlwaysTrue());

[BenchmarkCategory("Array")]
[Benchmark]
public bool CisternValueLinq_ValueLambda_Span() =>
Enumerable
.FromSpan<int[], int>(array, array => array.AsSpan())
.All(new AlwaysTrue());

[BenchmarkCategory("Array")]
[Benchmark]
public bool CisternValueLinq_ValueLambda_Memory() =>
memory
.OfMemory() // *shouldn't* need this!!! only because we are in the NetFabric.Hyperlinq namespace; so c# chooses incorrect overload
.All(new AlwaysTrue());

[BenchmarkCategory("Enumerable_Value")]
[Benchmark]
public bool CisternValueLinq_ValueLambda_Enumerable_Value() =>
enumerableValue
.OfEnumeratorConstraint<int, TestEnumerable.Enumerable, TestEnumerable.Enumerable.Enumerator>(x => x.GetEnumerator())
.All(new AlwaysTrue());

[BenchmarkCategory("Collection_Value")]
[Benchmark]
public bool CisternValueLinq_ValueLambda_Collection_Value() =>
collectionValue
.OfEnumeratorConstraint<int, TestCollection.Enumerable, TestCollection.Enumerable.Enumerator>(x => x.GetEnumerator(), collectionValue.Count)
.All(new AlwaysTrue());

[BenchmarkCategory("List_Value")]
[Benchmark]
public bool CisternValueLinq_ValueLambda_List_Value() =>
listValue
.OfReadOnlyListConstraint<int, TestList.Enumerable>()
.All(new AlwaysTrue());

[BenchmarkCategory("Enumerable_Reference")]
[Benchmark]
public bool CisternValueLinq_ValueLambda_Enumerable_Reference() =>
enumerableReference
.OfEnumerable() // *shouldn't* need this!!! only because we are in the NetFabric.Hyperlinq namespace; so c# chooses incorrect overload
.All(new AlwaysTrue());

[BenchmarkCategory("Collection_Reference")]
[Benchmark]
public bool CisternValueLinq_ValueLambda_Collection_Reference() =>
collectionReference
.OfEnumerable() // *shouldn't* need this!!! only because we are in the NetFabric.Hyperlinq namespace; so c# chooses incorrect overload
.All(new AlwaysTrue());

[BenchmarkCategory("List_Reference")]
[Benchmark]
public bool CisternValueLinq_ValueLambda_List_Reference() =>
listReference
.OfEnumerable() // *shouldn't* need this!!! only because we are in the NetFabric.Hyperlinq namespace; so c# chooses incorrect overload
.All(new AlwaysTrue());
}
}

#endif
2 changes: 1 addition & 1 deletion NetFabric.Hyperlinq.Benchmarks/Benchmarks/AllBenchmarks.cs
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ namespace NetFabric.Hyperlinq.Benchmarks
{
[GroupBenchmarksBy(BenchmarkLogicalGroupRule.ByCategory)]
[CategoriesColumn]
public class AllBenchmarks : RandomBenchmarksBase
public partial class AllBenchmarks : RandomBenchmarksBase
{
[BenchmarkCategory("Array")]
[Benchmark(Baseline = true)]
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#if !(NETCOREAPP2_1 || NET48)

using BenchmarkDotNet.Attributes;
using Cistern.ValueLinq;

namespace NetFabric.Hyperlinq.Benchmarks
{
public partial class SelectManyBenchmarks : RandomBenchmarksBase
{
[BenchmarkCategory("Array")]
[Benchmark]
public int CisternValueLinq_Array() =>
array
.SelectMany(item => Enumerable.Return(item))
.Sum();


[BenchmarkCategory("Array")]
[Benchmark]
public int CisternValueLinq_Memory() =>
memory
.SelectMany(item => Enumerable.Return(item))
.Sum();

[BenchmarkCategory("Enumerable_Value")]
[Benchmark]
public int CisternValueLinq_Enumerable_Value() =>
enumerableValue
.OfEnumeratorConstraint<int, TestEnumerable.Enumerable, TestEnumerable.Enumerable.Enumerator>(x => x.GetEnumerator())
.SelectMany(item => Enumerable.Return(item))
.Sum();

[BenchmarkCategory("Collection_Value")]
[Benchmark]
public int CisternValueLinq_Collection_Value() =>
collectionValue
.OfEnumeratorConstraint<int, TestCollection.Enumerable, TestCollection.Enumerable.Enumerator>(x => x.GetEnumerator(), collectionValue.Count)
.SelectMany(item => Enumerable.Return(item))
.Sum();

[BenchmarkCategory("List_Value")]
[Benchmark]
public int CisternValueLinq_List_Value() =>
listValue
.OfReadOnlyListConstraint<int, TestList.Enumerable>()
.SelectMany(item => Enumerable.Return(item))
.Sum();

[BenchmarkCategory("Enumerable_Reference")]
[Benchmark]
public int CisternValueLinq_Enumerable_Reference() =>
enumerableReference
.SelectMany(item => Enumerable.Return(item))
.Sum();

[BenchmarkCategory("Collection_Reference")]
[Benchmark]
public int CisternValueLinq_Collection_Reference() =>
collectionReference
.SelectMany(item => Enumerable.Return(item))
.Sum();

[BenchmarkCategory("List_Reference")]
[Benchmark]
public int CisternValueLinq_List_Reference() =>
listReference
.SelectMany(item => Enumerable.Return(item))
.Sum();
}
}

#endif
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ namespace NetFabric.Hyperlinq.Benchmarks
{
[GroupBenchmarksBy(BenchmarkLogicalGroupRule.ByCategory)]
[CategoriesColumn]
public class SelectManyBenchmarks : RandomBenchmarksBase
public partial class SelectManyBenchmarks : RandomBenchmarksBase
{
[BenchmarkCategory("Array")]
[Benchmark(Baseline = true)]
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
#if !(NETCOREAPP2_1 || NET48)

using BenchmarkDotNet.Attributes;
using Cistern.ValueLinq;
using System;

namespace NetFabric.Hyperlinq.Benchmarks
{
public partial class WhereSelectBenchmarks: RandomBenchmarksBase
{
[BenchmarkCategory("Array")]
[Benchmark]
public int CisternValueLinq_Array() =>
array
.OfArray() // *shouldn't* need this!!! only because we are in the NetFabric.Hyperlinq namespace; so c# chooses incorrect overload
.Where(item => (item & 0x01) == 0)
.Select(item => item)
.Sum();

[BenchmarkCategory("Array")]
[Benchmark]
public int CisternValueLinq_Span() =>
Enumerable
.FromSpan<int[], int>(array, array => array.AsSpan())
.Where(item => (item & 0x01) == 0)
.Select(item => item)
.Sum();

[BenchmarkCategory("Array")]
[Benchmark]
public int CisternValueLinq_Memory() =>
memory
.Where(item => (item & 0x01) == 0)
.Select(item => item)
.Sum();

[BenchmarkCategory("Enumerable_Value")]
[Benchmark]
public int CisternValueLinq_Enumerable_Value() =>
enumerableValue
.OfEnumeratorConstraint<int, TestEnumerable.Enumerable, TestEnumerable.Enumerable.Enumerator>(x => x.GetEnumerator())
.Where(item => (item & 0x01) == 0)
.Select(item => item)
.Sum();

[BenchmarkCategory("Collection_Value")]
[Benchmark]
public int CisternValueLinq_Collection_Value() =>
collectionValue
.OfEnumeratorConstraint<int, TestCollection.Enumerable, TestCollection.Enumerable.Enumerator>(x => x.GetEnumerator(), collectionValue.Count)
.Where(item => (item & 0x01) == 0)
.Select(item => item)
.Sum();

[BenchmarkCategory("List_Value")]
[Benchmark]
public int CisternValueLinq_List_Value() =>
listValue
.OfReadOnlyListConstraint<int, TestList.Enumerable>()
.Where(item => (item & 0x01) == 0)
.Select(item => item)
.Sum();

[BenchmarkCategory("Enumerable_Reference")]
[Benchmark]
public int CisternValueLinq_Enumerable_Reference() =>
enumerableReference
.OfEnumerable() // *shouldn't* need this!!! only because we are in the NetFabric.Hyperlinq namespace; so c# chooses incorrect overload
.Where(item => (item & 0x01) == 0)
.Select(item => item)
.Sum();

[BenchmarkCategory("Collection_Reference")]
[Benchmark]
public int CisternValueLinq_Collection_Reference() =>
collectionReference
.OfEnumerable() // *shouldn't* need this!!! only because we are in the NetFabric.Hyperlinq namespace; so c# chooses incorrect overload
.Where(item => (item & 0x01) == 0)
.Select(item => item)
.Sum();

[BenchmarkCategory("List_Reference")]
[Benchmark]
public int CisternValueLinq_List_Reference() =>
listReference
.OfEnumerable() // *shouldn't* need this!!! only because we are in the NetFabric.Hyperlinq namespace; so c# chooses incorrect overload
.Where(item => (item & 0x01) == 0)
.Select(item => item)
.Sum();

// ------

struct IsEven : IFunc<int, bool> { public bool Invoke(int item) => (item & 0x01) == 0; }
struct Identity : IFunc<int, int> { public int Invoke(int item) => item; }

[BenchmarkCategory("Array")]
[Benchmark]
public int CisternValueLinq_ValueLambda_Array() =>
array
.Where(new IsEven())
.Select(new Identity(), default(int))
.Sum();

[BenchmarkCategory("Enumerable_Value")]
[Benchmark]
public int CisternValueLinq_ValueLambda_Enumerable_Value() =>
enumerableValue
.OfEnumeratorConstraint<int, TestEnumerable.Enumerable, TestEnumerable.Enumerable.Enumerator>(x => x.GetEnumerator())
.Where(new IsEven())
.Select(new Identity(), default(int))
.Sum();

[BenchmarkCategory("Collection_Value")]
[Benchmark]
public int CisternValueLinq_ValueLambda_Collection_Value() =>
collectionValue
.OfEnumeratorConstraint<int, TestCollection.Enumerable, TestCollection.Enumerable.Enumerator>(x => x.GetEnumerator(), collectionValue.Count)
.Where(new IsEven())
.Select(new Identity(), default(int))
.Sum();

[BenchmarkCategory("List_Value")]
[Benchmark]
public int CisternValueLinq_ValueLambda_List_Value() =>
listValue
.OfReadOnlyListConstraint<int, TestList.Enumerable>()
.Where(new IsEven())
.Select(new Identity(), default(int))
.Sum();

[BenchmarkCategory("Enumerable_Reference")]
[Benchmark]
public int CisternValueLinq_ValueLambda_Enumerable_Reference() =>
enumerableReference
.Where(new IsEven())
.Select(new Identity(), default(int))
.Sum();

[BenchmarkCategory("Collection_Reference")]
[Benchmark]
public int CisternValueLinq_ValueLambda_Collection_Reference() =>
collectionReference
.Where(new IsEven())
.Select(new Identity(), default(int))
.Sum();

[BenchmarkCategory("List_Reference")]
[Benchmark]
public int CisternValueLinq_ValueLambda_List_Reference() =>
listReference
.Where(new IsEven())
.Select(new Identity(), default(int))
.Sum();
}
}
#endif
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ namespace NetFabric.Hyperlinq.Benchmarks
{
[GroupBenchmarksBy(BenchmarkLogicalGroupRule.ByCategory)]
[CategoriesColumn]
public class WhereSelectBenchmarks: RandomBenchmarksBase
public partial class WhereSelectBenchmarks: RandomBenchmarksBase
{
[BenchmarkCategory("Array")]
[Benchmark(Baseline = true)]
Original file line number Diff line number Diff line change
@@ -23,4 +23,16 @@
<PackageReference Include="System.Linq.Async" Version="4.1.1" />
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="5.0.0-rc.1.20451.14" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<PackageReference Include="Cistern.ValueLinq">
<Version>0.0.5</Version>
</PackageReference>
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
<PackageReference Include="Cistern.ValueLinq">
<Version>0.0.5</Version>
</PackageReference>
</ItemGroup>
</Project>