From 94b9753f162f55f610c02e23181f6d6248f3d1f3 Mon Sep 17 00:00:00 2001 From: prozolic <42107886+prozolic@users.noreply.github.com> Date: Sat, 23 Aug 2025 19:28:27 +0900 Subject: [PATCH 1/5] Add benchmark for ImmutableArrayExtensions --- .../System.Linq/ImmutableArrayExtensions.cs | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/benchmarks/micro/libraries/System.Linq/ImmutableArrayExtensions.cs diff --git a/src/benchmarks/micro/libraries/System.Linq/ImmutableArrayExtensions.cs b/src/benchmarks/micro/libraries/System.Linq/ImmutableArrayExtensions.cs new file mode 100644 index 00000000000..2ff982df55d --- /dev/null +++ b/src/benchmarks/micro/libraries/System.Linq/ImmutableArrayExtensions.cs @@ -0,0 +1,34 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using BenchmarkDotNet.Attributes; +using MicroBenchmarks; +using System.Collections.Generic; +using System.Collections.Immutable; + +namespace System.Linq.Tests +{ + [BenchmarkCategory(Categories.Libraries, Categories.LINQ)] + public class ImmutableArrayExtensions + { + private ImmutableArray _immutableArray; + + [GlobalSetup] + public void GlobalSetup() => _immutableArray = ImmutableArray.CreateRange(Enumerable.Range(0, LinqTestData.Size)); + + public IEnumerable Arguments() + { + yield return LinqTestData.IEnumerable; + yield return LinqTestData.ICollection; + yield return LinqTestData.IList; + yield return LinqTestData.Array; + } + + [Benchmark] + [ArgumentsSource(nameof(Arguments))] + [MemoryRandomization] + public bool SequenceEqual(LinqTestData input) => _immutableArray.SequenceEqual(input.Collection); + + } +} From 91648c041f682225b4cf6797c938957486ebeddf Mon Sep 17 00:00:00 2001 From: prozolic <42107886+prozolic@users.noreply.github.com> Date: Tue, 26 Aug 2025 07:23:30 +0900 Subject: [PATCH 2/5] Update src/benchmarks/micro/libraries/System.Linq/ImmutableArrayExtensions.cs Agreed, adding it. Co-authored-by: xtqqczze <45661989+xtqqczze@users.noreply.github.com> --- .../micro/libraries/System.Linq/ImmutableArrayExtensions.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/benchmarks/micro/libraries/System.Linq/ImmutableArrayExtensions.cs b/src/benchmarks/micro/libraries/System.Linq/ImmutableArrayExtensions.cs index 2ff982df55d..2f7ad7ca897 100644 --- a/src/benchmarks/micro/libraries/System.Linq/ImmutableArrayExtensions.cs +++ b/src/benchmarks/micro/libraries/System.Linq/ImmutableArrayExtensions.cs @@ -23,6 +23,7 @@ public IEnumerable Arguments() yield return LinqTestData.ICollection; yield return LinqTestData.IList; yield return LinqTestData.Array; + yield return LinqTestData.List; } [Benchmark] From 60488d3442c4f8d781fb9c3d94fd195c9fc7111b Mon Sep 17 00:00:00 2001 From: prozolic <42107886+prozolic@users.noreply.github.com> Date: Tue, 26 Aug 2025 07:26:22 +0900 Subject: [PATCH 3/5] Update src/benchmarks/micro/libraries/System.Linq/ImmutableArrayExtensions.cs Co-authored-by: xtqqczze <45661989+xtqqczze@users.noreply.github.com> --- .../micro/libraries/System.Linq/ImmutableArrayExtensions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/benchmarks/micro/libraries/System.Linq/ImmutableArrayExtensions.cs b/src/benchmarks/micro/libraries/System.Linq/ImmutableArrayExtensions.cs index 2f7ad7ca897..ce42167b147 100644 --- a/src/benchmarks/micro/libraries/System.Linq/ImmutableArrayExtensions.cs +++ b/src/benchmarks/micro/libraries/System.Linq/ImmutableArrayExtensions.cs @@ -10,7 +10,7 @@ namespace System.Linq.Tests { [BenchmarkCategory(Categories.Libraries, Categories.LINQ)] - public class ImmutableArrayExtensions + public class Perf_ImmutableArrayExtensions { private ImmutableArray _immutableArray; From 723350bd10ce92a033ca1c28cfac3ce83e29f0e5 Mon Sep 17 00:00:00 2001 From: prozolic <42107886+prozolic@users.noreply.github.com> Date: Tue, 26 Aug 2025 07:35:15 +0900 Subject: [PATCH 4/5] Rename ImmutableArrayExtensions.cs to Perf.ImmutableArrayExtensions.cs --- ...mutableArrayExtensions.cs => Perf.ImmutableArrayExtensions.cs} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/benchmarks/micro/libraries/System.Linq/{ImmutableArrayExtensions.cs => Perf.ImmutableArrayExtensions.cs} (100%) diff --git a/src/benchmarks/micro/libraries/System.Linq/ImmutableArrayExtensions.cs b/src/benchmarks/micro/libraries/System.Linq/Perf.ImmutableArrayExtensions.cs similarity index 100% rename from src/benchmarks/micro/libraries/System.Linq/ImmutableArrayExtensions.cs rename to src/benchmarks/micro/libraries/System.Linq/Perf.ImmutableArrayExtensions.cs From 50009f98c6c2b0f58774a49bb68f9e5b920464dd Mon Sep 17 00:00:00 2001 From: prozolic <42107886+prozolic@users.noreply.github.com> Date: Fri, 29 Aug 2025 13:41:21 +0900 Subject: [PATCH 5/5] Update src/benchmarks/micro/libraries/System.Linq/Perf.ImmutableArrayExtensions.cs Co-authored-by: xtqqczze <45661989+xtqqczze@users.noreply.github.com> --- .../libraries/System.Linq/Perf.ImmutableArrayExtensions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/benchmarks/micro/libraries/System.Linq/Perf.ImmutableArrayExtensions.cs b/src/benchmarks/micro/libraries/System.Linq/Perf.ImmutableArrayExtensions.cs index ce42167b147..1d0025e6163 100644 --- a/src/benchmarks/micro/libraries/System.Linq/Perf.ImmutableArrayExtensions.cs +++ b/src/benchmarks/micro/libraries/System.Linq/Perf.ImmutableArrayExtensions.cs @@ -29,7 +29,7 @@ public IEnumerable Arguments() [Benchmark] [ArgumentsSource(nameof(Arguments))] [MemoryRandomization] - public bool SequenceEqual(LinqTestData input) => _immutableArray.SequenceEqual(input.Collection); + public bool SequenceEqual(LinqTestData input) => ImmutableArrayExtensions.SequenceEqual(_immutableArray, input.Collection); } }