You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[mono] Array.IndexOf / Span<T>.IndexOf very slow on .net 7 #78008
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
Activity
teo-tsirpanis commentedon Nov 8, 2022
Related to #75996?
SamMonoRT commentedon May 18, 2023
@gemSender - this should be fixed in recent builds. Can we close this issue?