This media is not supported in your browser
VIEW IN TELEGRAM
π€£4π1π₯1π³1π―1
Just finished reading the huge Performance Improvements in .NET 10 article.
Thereβs a ton of interesting stuff in there, and I might eventually write a βsmallβ summary of it. But for now, hereβs a new #random_PoK (random Piece of Knowledge) :
Finally .NET has dedicated
No more monstrous
Also β .NET Conf kicks off today!
Donβt miss it: https://www.dotnetconf.net/ πππ
Thereβs a ton of interesting stuff in there, and I might eventually write a βsmallβ summary of it. But for now, hereβs a new #random_PoK (random Piece of Knowledge) :
Finally .NET has dedicated
LeftJoin and RightJoin LINQ methods!No more monstrous
GroupJoin + SelectMany + DefaultIfEmpty constructs β and for LINQ to Objects, itβs even faster:[MemoryDiagnoser(displayGenColumns: false)]
[HideColumns("Job", "Error", "StdDev", "Median", "RatioSD")]
public partial class Tests
{
private IEnumerable<int> Outer { get; } = Enumerable.Sequence(0, 1000, 2);
private IEnumerable<int> Inner { get; } = Enumerable.Sequence(0, 1000, 3);
[Benchmark(Baseline = true)]
public int LeftJoin_Manual() =>
ManualLeftJoin(Outer, Inner, o => o, i => i, (o, i) => o + i).Count();
[Benchmark]
public int LeftJoin_Linq() =>
Outer.LeftJoin(Inner, o => o, i => i, (o, i) => o + i).Count();
private static IEnumerable<TResult> ManualLeftJoin<TOuter, TInner, TKey, TResult>(
IEnumerable<TOuter> outer, IEnumerable<TInner> inner,
Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector,
Func<TOuter, TInner?, TResult> resultSelector) =>
outer
.GroupJoin(inner, outerKeySelector, innerKeySelector, (o, inners) => (o, inners))
.SelectMany(x => x.inners.DefaultIfEmpty(), (x, i) => resultSelector(x.o, i));
}
|Method |Mean |Ratio|Allocated|Alloc Ratio|
|---------------|--------|-----|---------|-----------|
|LeftJoin_Manual|29.02 us|1.00 |65.84 KB |1.00 |
|LeftJoin_Linq |15.23 us|0.53 |36.95 KB |0.56 |
Also β .NET Conf kicks off today!
Donβt miss it: https://www.dotnetconf.net/ πππ
π₯3β€2π1