Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
aalmada committed Mar 15, 2021
1 parent c7b7509 commit 080c6c9
Show file tree
Hide file tree
Showing 60 changed files with 349 additions and 617 deletions.
47 changes: 9 additions & 38 deletions Benchmarks/SingleBenchmarks.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[SingleBenchmarks.cs](../NetFabric.Hyperlinq.Benchmarks/Benchmarks/SingleBenchmarks.cs)

### References:
- Linq: 5.0.3
- Linq: 6.0.0-preview.2.21154.6
- System.Linq.Async: [5.0.0](https://www.nuget.org/packages/System.Linq.Async/5.0.0)
- System.Interactive: [5.0.0](https://www.nuget.org/packages/System.Interactive/5.0.0)
- System.Interactive.Async: [5.0.0](https://www.nuget.org/packages/System.Interactive.Async/5.0.0)
Expand All @@ -14,44 +14,15 @@
### Results:
``` ini

BenchmarkDotNet=v0.12.1, OS=Windows 10.0.19043
BenchmarkDotNet=v0.12.1.1521-nightly, OS=Windows 10.0.19043
Intel Core i7-7567U CPU 3.50GHz (Kaby Lake), 1 CPU, 4 logical and 2 physical cores
.NET Core SDK=6.0.100-preview.1.21103.13
[Host] : .NET Core 5.0.3 (CoreCLR 5.0.321.7212, CoreFX 5.0.321.7212), X64 RyuJIT
.NET Core 5.0 : .NET Core 5.0.3 (CoreCLR 5.0.321.7212, CoreFX 5.0.321.7212), X64 RyuJIT
.NET SDK=6.0.100-preview.2.21155.3
[Host] : .NET 6.0.0 (6.0.21.15406), X64 RyuJIT
.NET 6.0 : .NET 6.0.0 (6.0.21.15406), X64 RyuJIT

Job=.NET Core 5.0 Runtime=.NET Core 5.0
Job=.NET 6.0 Runtime=.NET 6.0 Categories=AsyncEnumerable_Value

```
| Method | Categories | Count | Mean | Error | StdDev | Ratio | RatioSD | Gen 0 | Gen 1 | Gen 2 | Allocated |
|------------------------------------ |-------------------------- |------ |----------:|----------:|----------:|------:|--------:|-------:|------:|------:|----------:|
| Linq_Array | Array | 1 | 11.808 ns | 0.2634 ns | 0.5011 ns | 1.00 | 0.00 | - | - | - | - |
| Hyperlinq_Array | Array | 1 | 13.928 ns | 0.0230 ns | 0.0192 ns | 1.20 | 0.05 | - | - | - | - |
| | | | | | | | | | | | |
| Linq_Enumerable_Value | Enumerable_Value | 1 | 23.083 ns | 0.1199 ns | 0.1062 ns | 1.00 | 0.00 | 0.0153 | - | - | 32 B |
| Hyperlinq_Enumerable_Value | Enumerable_Value | 1 | 16.547 ns | 0.0383 ns | 0.0359 ns | 0.72 | 0.00 | - | - | - | - |
| | | | | | | | | | | | |
| Linq_Collection_Value | Collection_Value | 1 | 23.476 ns | 0.4181 ns | 0.6986 ns | 1.00 | 0.00 | 0.0153 | - | - | 32 B |
| Hyperlinq_Collection_Value | Collection_Value | 1 | 18.673 ns | 0.0344 ns | 0.0322 ns | 0.79 | 0.03 | - | - | - | - |
| | | | | | | | | | | | |
| Linq_List_Value | List_Value | 1 | 7.425 ns | 0.0417 ns | 0.0348 ns | 1.00 | 0.00 | - | - | - | - |
| Hyperlinq_List_Value | List_Value | 1 | 22.084 ns | 0.0572 ns | 0.0507 ns | 2.97 | 0.02 | - | - | - | - |
| | | | | | | | | | | | |
| Linq_AsyncEnumerable_Value | AsyncEnumerable_Value | 1 | 89.296 ns | 0.1602 ns | 0.1420 ns | 1.00 | 0.00 | 0.0191 | - | - | 40 B |
| Hyperlinq_AsyncEnumerable_Value | AsyncEnumerable_Value | 1 | NA | NA | NA | ? | ? | - | - | - | - |
| | | | | | | | | | | | |
| Linq_Enumerable_Reference | Enumerable_Reference | 1 | 17.964 ns | 0.0869 ns | 0.0813 ns | 1.00 | 0.00 | 0.0153 | - | - | 32 B |
| Hyperlinq_Enumerable_Reference | Enumerable_Reference | 1 | 15.953 ns | 0.0711 ns | 0.0630 ns | 0.89 | 0.01 | 0.0153 | - | - | 32 B |
| | | | | | | | | | | | |
| Linq_Collection_Reference | Collection_Reference | 1 | 18.071 ns | 0.1005 ns | 0.0891 ns | 1.00 | 0.00 | 0.0153 | - | - | 32 B |
| Hyperlinq_Collection_Reference | Collection_Reference | 1 | 16.254 ns | 0.0875 ns | 0.1864 ns | 0.91 | 0.01 | 0.0153 | - | - | 32 B |
| | | | | | | | | | | | |
| Linq_List_Reference | List_Reference | 1 | 7.401 ns | 0.1724 ns | 0.1693 ns | 1.00 | 0.00 | - | - | - | - |
| Hyperlinq_List_Reference | List_Reference | 1 | 22.010 ns | 0.0530 ns | 0.0496 ns | 2.97 | 0.07 | - | - | - | - |
| | | | | | | | | | | | |
| Linq_AsyncEnumerable_Reference | AsyncEnumerable_Reference | 1 | 84.754 ns | 0.2935 ns | 0.2602 ns | 1.00 | 0.00 | 0.0191 | - | - | 40 B |
| Hyperlinq_AsyncEnumerable_Reference | AsyncEnumerable_Reference | 1 | NA | NA | NA | ? | ? | - | - | - | - |

Benchmarks with issues:
SingleBenchmarks.Hyperlinq_AsyncEnumerable_Value: .NET Core 5.0(Runtime=.NET Core 5.0) [Count=1]
SingleBenchmarks.Hyperlinq_AsyncEnumerable_Reference: .NET Core 5.0(Runtime=.NET Core 5.0) [Count=1]
| Method | Count | Mean | Error | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|-------------------------------- |------ |---------:|---------:|---------:|------:|------:|------:|----------:|
| Hyperlinq_AsyncEnumerable_Value | 1 | 84.27 ns | 0.499 ns | 0.443 ns | - | - | - | - |
1 change: 0 additions & 1 deletion NetFabric.Hyperlinq.Benchmarks/Benchmarks/AllBenchmarks.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using System;
using System.Linq;
using System.Threading.Tasks;

Expand Down
1 change: 0 additions & 1 deletion NetFabric.Hyperlinq.Benchmarks/Benchmarks/AnyBenchmarks.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using System;
using System.Linq;
using System.Threading.Tasks;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using System;
using System.Linq;
using System.Threading.Tasks;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using System;
using System.Linq;
using System.Threading.Tasks;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using StructLinq;
using System;
using System.Linq;
using System.Threading.Tasks;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using System;
using System.Linq;
using System.Threading.Tasks;

Expand Down
4 changes: 0 additions & 4 deletions NetFabric.Hyperlinq.Benchmarks/Benchmarks/EmptyBenchmarks.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using StructLinq;

namespace NetFabric.Hyperlinq.Benchmarks
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using System;
using System.Linq;
using System.Threading.Tasks;

Expand Down
3 changes: 0 additions & 3 deletions NetFabric.Hyperlinq.Benchmarks/Benchmarks/RangeBenchmarks.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using BenchmarkDotNet.Attributes;
Expand Down
3 changes: 0 additions & 3 deletions NetFabric.Hyperlinq.Benchmarks/Benchmarks/RepeatBenchmarks.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using BenchmarkDotNet.Attributes;
Expand Down
4 changes: 0 additions & 4 deletions NetFabric.Hyperlinq.Benchmarks/Benchmarks/ReturnBenchmarks.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using StructLinq;

namespace NetFabric.Hyperlinq.Benchmarks
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using StructLinq;
using System;
using System.Linq;
using System.Threading.Tasks;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using StructLinq;
using System;
using System.Linq;
using System.Threading.Tasks;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using BenchmarkDotNet.Configs;
using JM.LinqFaster.SIMD;
using StructLinq;
using System;
using System.Linq;
using System.Threading.Tasks;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using StructLinq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
Expand Down Expand Up @@ -32,6 +31,12 @@ public List<int> Linq_Collection_Value()
public List<int> Linq_List_Value()
=> listValue.Select(item => item).ToList();

[BenchmarkCategory("AsyncEnumerable_Value")]
[Benchmark(Baseline = true)]
public ValueTask<List<int>> Linq_AsyncEnumerable_Value()
=> asyncEnumerableValue.Select(item => item)
.ToListAsync();

[BenchmarkCategory("Enumerable_Reference")]
[Benchmark(Baseline = true)]
public List<int> Linq_Enumerable_Reference()
Expand All @@ -47,6 +52,12 @@ public List<int> Linq_Collection_Reference()
public List<int> Linq_List_Reference()
=> listReference.Select(item => item).ToList();

[BenchmarkCategory("AsyncEnumerable_Reference")]
[Benchmark(Baseline = true)]
public ValueTask<List<int>> Linq_AsyncEnumerable_Reference()
=> asyncEnumerableReference.Select(item => item)
.ToListAsync();

// ---------------------------------------------------------------------

[BenchmarkCategory("Array")]
Expand Down
3 changes: 0 additions & 3 deletions NetFabric.Hyperlinq.Benchmarks/Benchmarks/SingleBenchmarks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;

namespace NetFabric.Hyperlinq.Benchmarks
Expand Down
1 change: 0 additions & 1 deletion NetFabric.Hyperlinq.Benchmarks/Benchmarks/SumBenchmarks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using BenchmarkDotNet.Configs;
using JM.LinqFaster.SIMD;
using StructLinq;
using System;
using System.Linq;
using System.Threading.Tasks;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using StructLinq;
using System;
using System.Linq;
using System.Threading.Tasks;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using StructLinq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using StructLinq;
using System;
using System.Linq;
using System.Threading.Tasks;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using System;
using System.Linq;
using System.Threading.Tasks;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using StructLinq;
using System;
using System.Linq;
using System.Threading.Tasks;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using StructLinq;
using System;
using System.Linq;
using System.Threading.Tasks;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using StructLinq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
Expand Down
1 change: 0 additions & 1 deletion NetFabric.Hyperlinq.Benchmarks/BenchmarksBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using BenchmarkDotNet.Jobs;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;

namespace NetFabric.Hyperlinq.Benchmarks
{
Expand Down
2 changes: 1 addition & 1 deletion NetFabric.Hyperlinq.Benchmarks/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ static string GetInformationalVersion(Assembly assembly)
{
var dir = Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location);

while (!string.IsNullOrEmpty(dir))
while (dir is not null and { Length: not 0 })
{
if (Directory.EnumerateFiles(dir, "*.sln", SearchOption.TopDirectoryOnly).Any())
return dir;
Expand Down
4 changes: 1 addition & 3 deletions NetFabric.Hyperlinq.Benchmarks/SequentialBenchmarksBase.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using BenchmarkDotNet.Attributes;

namespace NetFabric.Hyperlinq.Benchmarks
namespace NetFabric.Hyperlinq.Benchmarks
{
public abstract class SequentialBenchmarksBase : CountBenchmarksBase
{
Expand Down
3 changes: 1 addition & 2 deletions NetFabric.Hyperlinq.Benchmarks/Utils/TestAsyncEnumerable.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Threading;
Expand Down Expand Up @@ -59,7 +58,7 @@ public Enumerator(int[] array, CancellationToken cancellationToken)
public ValueTask<bool> MoveNextAsync()
{
cancellationToken.ThrowIfCancellationRequested();
return new ValueTask<bool>(++index < array.Length);
return new ValueTask<bool>(++index <= array.Length);
}

public ValueTask DisposeAsync()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public async Task ClassesWithOverloadsShouldNotGenerate(string[] paths)
{
new[] {
"TestData/Source/Any.ArraySegment.cs",
"TestData/Source/Any.ReadOnlyList.cs",
"TestData/Source/Any.ValueReadOnlyList.cs",
"TestData/Source/Any.ValueEnumerable.cs",
"TestData/Source/Any.ValueReadOnlyCollection.cs",
"TestData/Source/Where.ValueEnumerable.cs",
Expand All @@ -126,7 +126,7 @@ public async Task ClassesWithOverloadsShouldNotGenerate(string[] paths)
{
new[] {
"TestData/Source/Any.ArraySegment.cs",
"TestData/Source/Any.ReadOnlyList.cs",
"TestData/Source/Any.ValueReadOnlyList.cs",
"TestData/Source/Any.ValueEnumerable.cs",
"TestData/Source/Any.ValueReadOnlyCollection.cs",
"TestData/Source/Select.ArraySegment.cs",
Expand All @@ -138,7 +138,7 @@ public async Task ClassesWithOverloadsShouldNotGenerate(string[] paths)
{
new[] {
"TestData/Source/Any.ArraySegment.cs",
"TestData/Source/Any.ReadOnlyList.cs",
"TestData/Source/Any.ValueReadOnlyList.cs",
"TestData/Source/Any.ValueEnumerable.cs",
"TestData/Source/Any.ValueReadOnlyCollection.cs",
"TestData/Source/Select.ValueEnumerable.cs",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>preview</LangVersion>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>

Expand Down
12 changes: 10 additions & 2 deletions NetFabric.Hyperlinq.SourceGenerator/OverloadsGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,11 @@ string MapTypeProperties(IEnumerable<string> typePropertyNames, ITypeSymbol enum
})
.ToCommaSeparated();

return string.IsNullOrEmpty(str) ? string.Empty : $"<{str}>";
return str switch
{
{ Length: 0 } => string.Empty,
_ => $"<{str}>"
};
}

string MapTypeProperties(IEnumerable<string> typePropertyNames, GeneratorBindingsAttribute? bindingsAttribute)
Expand All @@ -396,7 +400,11 @@ string MapTypeProperties(IEnumerable<string> typePropertyNames, GeneratorBinding

str = StringExtensions.CommaSeparateIfNotNullOrEmpty(str, bindingsAttribute?.ExtraTypeParameters);

return string.IsNullOrEmpty(str) ? string.Empty : $"<{str}>";
return str switch
{
{ Length: 0 } => string.Empty,
_ => $"<{str}>"
};
}
}
}
Loading

0 comments on commit 080c6c9

Please sign in to comment.