Minimal Reproduce Example with C#13 being 3 times slower than C#10

Revision en2, by JasonMendoza2008, 2025-07-15 17:21:08

MRE:

using System.Collections.Generic;

namespace cp;

internal static class Codeforces
{
    public static void Main()
    {
        SortedSet<int> mySortedSet = new SortedSet<int>();
        for (int i = 0; i < 1000000; i++) {
            mySortedSet.Add(i);
        }
        Console.WriteLine(mySortedSet.Min);
        Console.WriteLine(mySortedSet.Max);
    }
}

1030 ms with C#13, 358 ms with C#10.

As a control, using https://dotnetfiddle.net/, I get 292 ms using C#10 and 357 using C#13 so yes a bit of an increase but by no means, a factor 3.

I think I've seen another blog talking about C#13 being weirdly slow but I have lost it, I thought a minimal reproducible example with no input parsing would help find the root cause.

Tags .net, c#

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en6 English JasonMendoza2008 2025-07-15 20:38:45 6
en5 English JasonMendoza2008 2025-07-15 17:23:41 3
en4 English JasonMendoza2008 2025-07-15 17:23:29 3 Tiny change: ' and [357 using C#1' -> ' and [357 ms using C#1'
en3 English JasonMendoza2008 2025-07-15 17:23:07 61
en2 English JasonMendoza2008 2025-07-15 17:21:08 23 Tiny change: 'ing about it but I hav' -> 'ing about C#13 being weirdly slow but I hav'
en1 English JasonMendoza2008 2025-07-15 17:20:13 960 Initial revision (published)