-
Notifications
You must be signed in to change notification settings - Fork 428
Expand file tree
/
Copy pathPerf_CommandLine_Help.cs
More file actions
57 lines (52 loc) · 2.04 KB
/
Copy pathPerf_CommandLine_Help.cs
File metadata and controls
57 lines (52 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System.CommandLine.Benchmarks.Helpers;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using BenchmarkDotNet.Attributes;
namespace System.CommandLine.Benchmarks.DragonFruit
{
/// <summary>
/// This is an end-to-end benchmark that measures the performance of --help option.
/// </summary>
[BenchmarkCategory(Categories.DragonFruit)]
[InvocationCount(3000)]
public class Perf_CommandLine_Help
{
private readonly NullConsole _nullConsole = new();
private Assembly _testAssembly;
private string _testAssemblyFilePath;
private string _testAssemblyXmlDocsFilePath;
[GlobalSetup]
public void Setup()
{
_testAssemblyFilePath = Utils.CreateTestAssemblyInTempFileFromFile(
"Sample1.Main.cs",
new[]
{
typeof(object).GetTypeInfo().Assembly.Location,
typeof(Enumerable).GetTypeInfo().Assembly.Location,
typeof(System.CommandLine.Invocation.InvocationContext).GetTypeInfo().Assembly.Location
}
);
_testAssembly = Assembly.Load(File.ReadAllBytes(_testAssemblyFilePath));
_testAssemblyXmlDocsFilePath = _testAssemblyFilePath.Replace(".dll", ".xml");
}
[Benchmark(Description = "--help")]
public async Task SearchForStartingPointWhenGivenEntryPointClass_Help()
=> await System.CommandLine.DragonFruit.CommandLine.ExecuteAssemblyAsync(
_testAssembly,
new[] { "--help" },
null,
_testAssemblyXmlDocsFilePath,
_nullConsole);
[GlobalCleanup]
public void Cleanup()
{
File.Delete(_testAssemblyFilePath);
File.Delete(_testAssemblyXmlDocsFilePath);
}
}
}