forked from chocolatey/choco
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request chocolatey#3460 from AdmiringWorm/benchmark
(ENGTASKS-3693) Prototype updating user agent with process information
- Loading branch information
Showing
22 changed files
with
1,984 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" /> | ||
</startup> | ||
<runtime> | ||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> | ||
<dependentAssembly> | ||
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" /> | ||
</dependentAssembly> | ||
<dependentAssembly> | ||
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-4.0.1.2" newVersion="4.0.1.2" /> | ||
</dependentAssembly> | ||
<dependentAssembly> | ||
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" /> | ||
</dependentAssembly> | ||
<dependentAssembly> | ||
<assemblyIdentity name="Microsoft.Extensions.DependencyInjection.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-8.0.0.1" newVersion="8.0.0.1" /> | ||
</dependentAssembly> | ||
<dependentAssembly> | ||
<assemblyIdentity name="Microsoft.Extensions.Logging.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-8.0.0.1" newVersion="8.0.0.1" /> | ||
</dependentAssembly> | ||
<dependentAssembly> | ||
<assemblyIdentity name="Microsoft.Extensions.Options" publicKeyToken="adb9793829ddae60" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-8.0.0.2" newVersion="8.0.0.2" /> | ||
</dependentAssembly> | ||
<dependentAssembly> | ||
<assemblyIdentity name="System.Diagnostics.DiagnosticSource" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-8.0.0.1" newVersion="8.0.0.1" /> | ||
</dependentAssembly> | ||
<dependentAssembly> | ||
<assemblyIdentity name="Microsoft.Bcl.AsyncInterfaces" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" /> | ||
</dependentAssembly> | ||
<dependentAssembly> | ||
<assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" /> | ||
</dependentAssembly> | ||
<dependentAssembly> | ||
<assemblyIdentity name="Microsoft.Diagnostics.NETCore.Client" publicKeyToken="31bf3856ad364e35" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-0.2.10.10501" newVersion="0.2.10.10501" /> | ||
</dependentAssembly> | ||
<dependentAssembly> | ||
<assemblyIdentity name="Microsoft.CodeAnalysis" publicKeyToken="31bf3856ad364e35" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-4.9.0.0" newVersion="4.9.0.0" /> | ||
</dependentAssembly> | ||
<dependentAssembly> | ||
<assemblyIdentity name="Microsoft.CodeAnalysis.CSharp" publicKeyToken="31bf3856ad364e35" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-4.9.0.0" newVersion="4.9.0.0" /> | ||
</dependentAssembly> | ||
<dependentAssembly> | ||
<assemblyIdentity name="System.CodeDom" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" /> | ||
</dependentAssembly> | ||
<dependentAssembly> | ||
<assemblyIdentity name="Iced" publicKeyToken="5baba79f4264913b" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-1.21.0.0" newVersion="1.21.0.0" /> | ||
</dependentAssembly> | ||
<dependentAssembly> | ||
<assemblyIdentity name="Microsoft.Diagnostics.Runtime" publicKeyToken="31bf3856ad364e35" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-3.1.10.12801" newVersion="3.1.10.12801" /> | ||
</dependentAssembly> | ||
<dependentAssembly> | ||
<assemblyIdentity name="Microsoft.Diagnostics.Tracing.TraceEvent" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-3.1.10.0" newVersion="3.1.10.0" /> | ||
</dependentAssembly> | ||
<dependentAssembly> | ||
<assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-4.1.4.0" newVersion="4.1.4.0" /> | ||
</dependentAssembly> | ||
</assemblyBinding> | ||
</runtime> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using BenchmarkDotNet.Analysers; | ||
using BenchmarkDotNet.Columns; | ||
using BenchmarkDotNet.Configs; | ||
using BenchmarkDotNet.Diagnosers; | ||
using BenchmarkDotNet.Environments; | ||
using BenchmarkDotNet.Exporters; | ||
using BenchmarkDotNet.Exporters.Csv; | ||
using BenchmarkDotNet.Jobs; | ||
using BenchmarkDotNet.Loggers; | ||
|
||
namespace chocolatey.benchmark | ||
{ | ||
internal static class BenchmarkConfig | ||
{ | ||
public static IConfig Get() | ||
{ | ||
var config = ManualConfig.CreateEmpty(); | ||
|
||
foreach (var platform in new[] { Platform.X64/*, Platform.X86*/ }) | ||
{ | ||
config = config.AddJob(Job.Default.WithRuntime(ClrRuntime.Net48).WithPlatform(platform).WithJit(Jit.LegacyJit)); | ||
} | ||
|
||
return config | ||
.AddDiagnoser(MemoryDiagnoser.Default) | ||
.AddColumnProvider(DefaultColumnProviders.Instance) | ||
.AddLogger(ConsoleLogger.Default) | ||
.AddExporter(CsvExporter.Default) | ||
.AddExporter(HtmlExporter.Default) | ||
.AddExporter(MarkdownExporter.Default) | ||
.AddExporter(AsciiDocExporter.Default) | ||
.AddAnalyser(GetAnalysers().ToArray()); | ||
} | ||
|
||
private static IEnumerable<IAnalyser> GetAnalysers() | ||
{ | ||
yield return EnvironmentAnalyser.Default; | ||
yield return OutliersAnalyser.Default; | ||
yield return MinIterationTimeAnalyser.Default; | ||
yield return MultimodalDistributionAnalyzer.Default; | ||
yield return RuntimeErrorAnalyser.Default; | ||
yield return ZeroMeasurementAnalyser.Default; | ||
yield return BaselineCustomAnalyzer.Default; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
using System.Runtime.CompilerServices; | ||
using BenchmarkDotNet.Attributes; | ||
using chocolatey.benchmark.helpers; | ||
using chocolatey.infrastructure.information; | ||
|
||
namespace chocolatey.benchmark | ||
{ | ||
public class ParentProcessBenchmarks | ||
{ | ||
[Benchmark, MethodImpl(MethodImplOptions.NoInlining)] | ||
public string GetParentProcessDocumentedPinvoke() | ||
{ | ||
return PinvokeProcessHelper.GetDocumentedParent(); | ||
} | ||
|
||
[Benchmark, MethodImpl(MethodImplOptions.NoInlining)] | ||
public string GetParentProcessFilteredDocumentedPinvoke() | ||
{ | ||
return PinvokeProcessHelper.GetDocumentedParentFiltered(); | ||
} | ||
|
||
[Benchmark, MethodImpl(MethodImplOptions.NoInlining)] | ||
public string GetParentProcessFilteredManaged() | ||
{ | ||
return ManagedProcessHelper.GetParent(); | ||
} | ||
|
||
[Benchmark, MethodImpl(MethodImplOptions.NoInlining)] | ||
public string GetParentProcessFilteredUndocumentedPinvoke() | ||
{ | ||
return PinvokeProcessHelper.GetUndocumentedParentFiltered(); | ||
} | ||
|
||
[Benchmark(Baseline = true), MethodImpl(MethodImplOptions.NoInlining)] | ||
public string GetParentProcessManaged() | ||
{ | ||
return ManagedProcessHelper.GetParent(); | ||
} | ||
|
||
[Benchmark, MethodImpl(MethodImplOptions.NoInlining)] | ||
public ProcessTree GetParentProcessTreeDocumentedPinvoke() | ||
{ | ||
return PinvokeProcessHelper.GetDocumentedProcessTree(); | ||
} | ||
|
||
[Benchmark, MethodImpl(MethodImplOptions.NoInlining)] | ||
public ProcessTree GetParentProcessTreeManaged() | ||
{ | ||
return ManagedProcessHelper.GetProcessTree(); | ||
} | ||
|
||
[Benchmark, MethodImpl(MethodImplOptions.NoInlining)] | ||
public ProcessTree GetParentProcessTreeUndocumentedPinvoke() | ||
{ | ||
return PinvokeProcessHelper.GetUndocumentedProcessTree(); | ||
} | ||
|
||
[Benchmark, MethodImpl(MethodImplOptions.NoInlining)] | ||
public string GetParentProcessUndocumentedPinvoke() | ||
{ | ||
return PinvokeProcessHelper.GetUndocumentedParent(); | ||
} | ||
[Benchmark, MethodImpl(MethodImplOptions.NoInlining)] | ||
public ProcessTree GetParentProcessTreeImplemented() | ||
{ | ||
return ProcessInformation.GetProcessTree(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Linq; | ||
using System.Runtime.CompilerServices; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using BenchmarkDotNet.Attributes; | ||
using chocolatey.benchmark.helpers; | ||
using chocolatey.infrastructure.information; | ||
|
||
namespace chocolatey.benchmark | ||
{ | ||
public class ProcessTreeBenchmark | ||
{ | ||
[Benchmark, MethodImpl(MethodImplOptions.NoInlining)] | ||
[ArgumentsSource(nameof(GetProcessTree))] | ||
public string GetFirstFilteredProcessName(ProcessTree tree) | ||
{ | ||
return tree.FirstFilteredProcessName; | ||
} | ||
|
||
[Benchmark, MethodImpl(MethodImplOptions.NoInlining)] | ||
[ArgumentsSource(nameof(GetProcessTree))] | ||
public string GetFirstProcessName(ProcessTree tree) | ||
{ | ||
return tree.FirstProcessName; | ||
} | ||
|
||
[Benchmark, MethodImpl(MethodImplOptions.NoInlining)] | ||
[ArgumentsSource(nameof(GetProcessTree))] | ||
public string GetLastFilteredProcessName(ProcessTree tree) | ||
{ | ||
return tree.LastFilteredProcessName; | ||
} | ||
|
||
[Benchmark, MethodImpl(MethodImplOptions.NoInlining)] | ||
[ArgumentsSource(nameof(GetProcessTree))] | ||
public string GetLastProcessName(ProcessTree tree) | ||
{ | ||
return tree.LastProcessName; | ||
} | ||
|
||
[Benchmark(Baseline = true), MethodImpl(MethodImplOptions.NoInlining)] | ||
[ArgumentsSource(nameof(GetProcessTree))] | ||
public LinkedList<string> GetProcessesList(ProcessTree tree) | ||
{ | ||
return tree.Processes; | ||
} | ||
|
||
public IEnumerable<object> GetProcessTree() | ||
{ | ||
var currentProcess = Process.GetCurrentProcess(); | ||
|
||
var tree = new ProcessTree(currentProcess.ProcessName); | ||
tree.Processes.AddLast("devenv"); | ||
tree.Processes.AddLast("cmd"); | ||
tree.Processes.AddLast("Tabby"); | ||
tree.Processes.AddLast("explorer"); | ||
yield return tree; | ||
|
||
yield return new ProcessTree(currentProcess.ProcessName); | ||
|
||
tree = new ProcessTree(currentProcess.ProcessName); | ||
tree.Processes.AddLast(currentProcess.ProcessName); | ||
tree.Processes.AddLast("WindowsTerminal"); | ||
yield return tree; | ||
|
||
yield return PinvokeProcessHelper.GetUndocumentedProcessTree(currentProcess); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System.Linq; | ||
using BenchmarkDotNet.Running; | ||
|
||
namespace chocolatey.benchmark | ||
{ | ||
internal class Program | ||
{ | ||
private static void Main(string[] args) | ||
{ | ||
var switcher = BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly); | ||
|
||
if (args.Length > 0) | ||
{ | ||
switcher.Run(args, BenchmarkConfig.Get()).ToArray(); | ||
} | ||
else | ||
{ | ||
switcher.RunAll(BenchmarkConfig.Get()).ToArray(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("chocolatey.benchmark")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("chocolatey.benchmark")] | ||
[assembly: AssemblyCopyright("Copyright © 2024")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("2b98bb42-a7ae-4ef6-b0b8-aa7bfc1e1180")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
Oops, something went wrong.