-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Closed
Labels
needs-more-infoNot enough information has been provided. Please share more detail as requested.Not enough information has been provided. Please share more detail as requested.
Description
Slow loop performance
I have the following code :
using System;
using System.Diagnostics;
using System.IO;
namespace ConsoleApp83
{
class Program
{
static void Main(string[] args)
{
const int count = 1024 * 64;
var buffer = new int[count];
var rand = new Random();
for (var i = 0; i < count; i++)
{
buffer[i] = rand.Next(count);
}
var sw = Stopwatch.StartNew();
for (var j = 0; j < 10000; j++)
for (var i = 0; i < buffer.Length; i++)
{
buffer[i] *= 3;
}
Console.WriteLine(sw.Elapsed);
}
}
}
I ran above code on Windows 10 with .net core sdk 3.0 preview, and it runs in 1.56 seconds
whereas on .net core 2.2, it runs within 0.54 seconds
. Both compiled with release mode and 64 bit.
Here's my output for dotnet --info:
PS C:\> dotnet --info
.NET Core SDK (reflecting any global.json):
Version: 3.0.100-preview-009812
Commit: e3abf6e935
Runtime Environment:
OS Name: Windows
OS Version: 10.0.17763
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\3.0.100-preview-009812\
Host (useful for support):
Version: 3.0.0-preview-27122-01
Commit: 00c5c8bc40
Metadata
Metadata
Assignees
Labels
needs-more-infoNot enough information has been provided. Please share more detail as requested.Not enough information has been provided. Please share more detail as requested.