-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Closed
Closed
Copy link
Labels
Milestone
Description
This was found in PowerShell Core6 (https://github.com/PowerShell/PowerShell) while investigating PowerShell cmdlet perf regression. I tracked the perf regression to this .Net type:
System.ServiceProcess.ServiceControllerUsing this type is approximately 30 times slower when running under .Net CoreApp 2.1
Repro steps:
using System;
using System.ServiceProcess;
namespace ConsoleApp3
{
class Program
{
static void Main(string[] args)
{
System.Console.WriteLine("Starting loop");
var start = DateTime.Now;
for (var i=0; i<100; i++)
{
var winRMService = new ServiceController("WinRM");
if (winRMService != null)
{
var status = winRMService.Status;
}
}
var end = DateTime.Now;
System.Console.WriteLine("End loop");
System.Console.WriteLine(String.Format("Time in milliseconds = {0}", (end - start).Milliseconds));
System.Console.WriteLine("Press any key to continue");
System.Console.ReadKey();
}
}
}Results:
Under .Net Core App 2.1
Time in milliseconds = 714
Under .Net Full CLR
Time in milliseconds = 24
Expected:
Use of ServiceController type should have approximately the same performance between each version of .Net.
Reactions are currently unavailable