Skip to content

Fastest Way to Generate a Random Boolean in C#: net11.0 update and benchmark fixes - #2427

Merged
vladimir-pecanac-main merged 2 commits into
CodeMazeBlog:mainfrom
vladimir-pecanac-main:seo/109796-csharp-fastest-way-to-generate-a-random-boolean
Dec 2, 2026
Merged

vladimir-pecanac-main merged 2 commits into
CodeMazeBlog:mainfrom
vladimir-pecanac-main:seo/109796-csharp-fastest-way-to-generate-a-random-boolean

Conversation

@vladimir-pecanac-main

Copy link
Copy Markdown
Collaborator

Moves both projects in numbers-csharp/GenerateRandomBooleans to net11.0 with BenchmarkDotNet 0.15.8 (InProcess on all seven benchmark classes), MSTest 4.5.3, Microsoft.NET.Test.Sdk 18.12.0, coverlet.collector 10.1.0 and NSubstitute 6.2.0. The direct GetItems benchmark now fills the first NumberOfBooleans items of the rented array (AsSpan(0, NumberOfBooleans)) instead of only its leftover tail, the NextIntegerBits vs NextInteger benchmark also measures GetItemsWithBufferGenerator, the fairness test header reads True, and the two GetItems test classes now each test their own generator.

…s, MSTest 4.5.3, NSubstitute 6.2.0

Fix the direct GetItems benchmark to fill AsSpan(0, NumberOfBooleans) instead of the tail of the rented array, add GetItemsWithBufferGenerator to the NextIntegerBits vs NextInteger benchmark, use a True header in the fairness test, and let each GetItems test class test its own generator.
@vladimir-pecanac-main
vladimir-pecanac-main merged commit c347585 into CodeMazeBlog:main Dec 2, 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