Skip to content

Quicksort Algorithm in C#: .NET 10 update and corrected benchmark - #2348

Open
vladimir-pecanac-main wants to merge 1 commit into
CodeMazeBlog:mainfrom
vladimir-pecanac-main:seo/68239-csharp-quicksort-algorithm
Open

vladimir-pecanac-main wants to merge 1 commit into
CodeMazeBlog:mainfrom
vladimir-pecanac-main:seo/68239-csharp-quicksort-algorithm

Conversation

@vladimir-pecanac-main

Copy link
Copy Markdown
Collaborator

Retargets csharp-algorithms/QuickSort 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. SortArray loses the benchmark-only fourth parameter so it matches the article, a middle-element pivot variant sits next to it, and a new QuickSortBenchmarks class copies the source array on every call so the unsorted case really is unsorted, comparing both pivots with Array.Sort at 200, 1000 and 2000 elements. The tests now cover the article's nine-element array, 2,000 random elements against Array.Sort, and 100,000 presorted elements with the middle pivot.

…and tests

Retarget both projects to net10.0 and update BenchmarkDotNet, MSTest, Test SDK and coverlet. SortArray drops the benchmark-only fourth parameter so it matches the article. The new QuickSortBenchmarks class copies the source array per call so unsorted input stays unsorted, and compares the first-element pivot, a middle-element pivot and Array.Sort at 200, 1000 and 2000 elements. Tests cover the article array, random input against Array.Sort, and 100,000 presorted elements with the middle pivot.
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