Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created CountBy benchmarks for 10_000, 100, 1, 0 iterations #4380

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 29 additions & 11 deletions src/benchmarks/micro/runtime/Linq/Linq.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,17 @@ private static void CreateLists()
[BenchmarkCategory(Categories.Runtime, Categories.LINQ)]
public class LinqBenchmarks
{
public const int IterationsWhere00 = 1000000;
public const int IterationsWhere01 = 250000;
public const int IterationsCount00 = 1000000;
public const int IterationsOrder00 = 25000;
public const int IterationsCountBy00 = 1000000;
public const int IterationsAggregateBy00 = 1000000;
public const int IterationsGroupBy00 = 1000000;
public const int IterationsWhere00 = 1_000_000;
public const int IterationsWhere01 = 250_000;
public const int IterationsCount00 = 1_000_000;
public const int IterationsOrder00 = 25_000;
public const int IterationsCountBy00 = 1_000_000;
public const int IterationsCountBy01 = 10_000;
public const int IterationsCountBy02 = 100;
public const int IterationsCountBy03 = 1;
public const int IterationsCountBy04 = 0;
public const int IterationsAggregateBy00 = 1_000_000;
public const int IterationsGroupBy00 = 1_000_000;

#region Where00

Expand Down Expand Up @@ -367,21 +371,35 @@ public bool Order00ManualX()
#region CountBy00

#if NET9_0_OR_GREATER
[Benchmark]
public bool CountBy00LinqMethodX()
public bool CountByLinqMethodX(int iterationsCount)
{
List<Product> products = Product.GetProductList();
int count = 0;
for (int i = 0; i < IterationsCountBy00; i++)
for (int i = 0; i < iterationsCount; i++)
{
count += products
.CountBy(p => p.Category)
.Count();
}

return (count == 5 * IterationsCountBy00);
return (count == 5 * iterationsCount);
}

[Benchmark]
public bool CountBy00LinqMethodX() => CountByLinqMethodX(IterationsCountBy00);

[Benchmark]
public bool CountBy01LinqMethodX() => CountByLinqMethodX(IterationsCountBy01);

[Benchmark]
public bool CountBy02LinqMethodX() => CountByLinqMethodX(IterationsCountBy02);

[Benchmark]
public bool CountBy03LinqMethodX() => CountByLinqMethodX(IterationsCountBy03);

[Benchmark]
public bool CountBy04LinqMethodX() => CountByLinqMethodX(IterationsCountBy04);

[Benchmark]
public bool CountBy00AggregateByX()
{
Expand Down
Loading