-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
Labels
Milestone
Description
Description
I built mono and bcl with command
.\build.cmd mono+libs -rf Mono -a x64 -c release -rc release -lc release
and run performance test for Array.IndexOf/Span.IndexOf.
Surprisingly, the time-consuming of mono of .net7 is more than 5 times higher than that mono of .net6.
below is the code for test
using System;
using System.Diagnostics;
class Program
{
private static int[] _testArray = InitAssistArray();
private static int[] InitAssistArray()
{
int[] assistArray = new int[2048];
Random r = new Random(5);
for (int i = 0; i < assistArray.Length; i++)
{
assistArray[i] = r.Next() % 2048;
}
return assistArray;
}
public static int FindIndex(int n)
{
int sum = 0;
for (int i = 0; i < n; i++)
{
sum += _testArray.AsSpan().IndexOf(i % 2048);
}
return sum;
}
public static void Main()
{
FindIndex(100);
Stopwatch sw = Stopwatch.StartNew();
int sum = FindIndex(100000);
sw.Stop();
Console.WriteLine($"time cost: {sw.ElapsedMilliseconds}");
}
}
Configuration
os: windows
architecture: x64
Regression?
Data
it cost about
18 ms on .net6 coreclr
76 ms on .net6 mono
435 ms on .net7(rc2) mono