Skip to content

Selection sort: .NET 10 and a copy-per-call benchmark - #2369

Merged
vladimir-pecanac-main merged 2 commits into
CodeMazeBlog:mainfrom
vladimir-pecanac-main:seo/62344-csharp-selection-sort
Nov 9, 2026
Merged

vladimir-pecanac-main merged 2 commits into
CodeMazeBlog:mainfrom
vladimir-pecanac-main:seo/62344-csharp-selection-sort

Conversation

@vladimir-pecanac-main

Copy link
Copy Markdown
Collaborator

Moves csharp-algorithms/SelectionSort to net10.0 with BenchmarkDotNet 0.15.8, MSTest 4.5.2, Microsoft.NET.Test.Sdk 18.11.0 and coverlet.collector 10.1.0. The benchmark moves out of Selection into a new SelectionBenchmarks class that copies its generated array into a work array on every call, so the random case no longer measures already sorted data after the first call, and it runs on random and sorted input at 200, 2,000 and 20,000 elements. Program.cs passes args to BenchmarkRunner, NumArray becomes a non-nullable property, the tests use (expected, actual) order, and two new tests check the method against Array.Sort on random data and on edge cases.

Both projects target net10.0 with BenchmarkDotNet 0.15.8, MSTest 4.5.2, Microsoft.NET.Test.Sdk 18.11.0 and coverlet.collector 10.1.0. The benchmark moves into SelectionBenchmarks, which copies its generated array into a work array on every call so the random case no longer sorts already sorted data after the first call. Program.cs passes args to BenchmarkRunner. Tests use (expected, actual) order and gain an Array.Sort oracle test and edge-case rows.
@vladimir-pecanac-main
vladimir-pecanac-main merged commit eebbbfe into CodeMazeBlog:main Nov 9, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant