Skip to content

Commit 7647116

Browse files
committed
[Union] Add case in benckmark.
1 parent 1f9373c commit 7647116

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

Documents/BenchmarksResults/Union.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,17 @@
77
``` ini
88

99
BenchmarkDotNet=v0.12.1, OS=Windows 10.0.19042
10-
Intel Core i7-8750H CPU 2.20GHz (Coffee Lake), 1 CPU, 12 logical and 6 physical cores
11-
.NET Core SDK=5.0.101
12-
[Host] : .NET Core 5.0.1 (CoreCLR 5.0.120.57516, CoreFX 5.0.120.57516), X64 RyuJIT
13-
DefaultJob : .NET Core 5.0.1 (CoreCLR 5.0.120.57516, CoreFX 5.0.120.57516), X64 RyuJIT
10+
Intel Core i7-7700 CPU 3.60GHz (Kaby Lake), 1 CPU, 8 logical and 4 physical cores
11+
.NET Core SDK=5.0.202
12+
[Host] : .NET Core 5.0.5 (CoreCLR 5.0.521.16609, CoreFX 5.0.521.16609), X64 RyuJIT
13+
DefaultJob : .NET Core 5.0.5 (CoreCLR 5.0.521.16609, CoreFX 5.0.521.16609), X64 RyuJIT
1414

1515

1616
```
17-
| Method | Mean | Error | StdDev | Ratio | Gen 0 | Gen 1 | Gen 2 | Allocated |
18-
|------------------------------- |---------:|--------:|--------:|------:|--------:|--------:|--------:|----------:|
19-
| Linq | 347.2 μs | 2.02 μs | 1.88 μs | 1.00 | 90.8203 | 90.8203 | 90.8203 | 524824 B |
20-
| StructLinq | 155.0 μs | 0.73 μs | 0.68 μs | 0.45 | - | - | - | 64 B |
21-
| StructLinqZeroAlloc | 155.6 μs | 0.47 μs | 0.41 μs | 0.45 | - | - | - | - |
22-
| StructLinqZeroAllocAndComparer | 121.2 μs | 0.43 μs | 0.40 μs | 0.35 | - | - | - | - |
17+
| Method | Mean | Error | StdDev | Ratio | Gen 0 | Gen 1 | Gen 2 | Allocated |
18+
|---------------------------------- |---------:|--------:|--------:|------:|--------:|--------:|--------:|----------:|
19+
| Linq | 424.0 μs | 8.27 μs | 7.74 μs | 1.00 | 90.8203 | 90.8203 | 90.8203 | 524824 B |
20+
| StructLinq | 184.9 μs | 2.72 μs | 2.42 μs | 0.44 | - | - | - | 64 B |
21+
| StructLinqZeroAlloc | 184.4 μs | 1.89 μs | 1.58 μs | 0.43 | - | - | - | - |
22+
| StructLinqZeroAllocAndComparer | 149.1 μs | 0.82 μs | 0.69 μs | 0.35 | - | - | - | - |
23+
| StructLinqZeroAllocAndComparerSum | 132.7 μs | 0.41 μs | 0.37 μs | 0.31 | - | - | - | - |

src/StructLinq.Benchmark/Union.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,14 @@ public int StructLinqZeroAllocAndComparer()
6363
return sum;
6464
}
6565

66+
[Benchmark]
67+
public int StructLinqZeroAllocAndComparerSum()
68+
{
69+
var comparer = new DefaultStructEqualityComparer();
70+
return array1.ToStructEnumerable()
71+
.Union(array2.ToStructEnumerable(), comparer, x=> x, x=>x)
72+
.Sum(x=>x);
73+
}
74+
6675
}
6776
}

0 commit comments

Comments
 (0)