-
Notifications
You must be signed in to change notification settings - Fork 417
Expand file tree
/
Copy pathPerf_Parser_Directives_Suggest.cs
More file actions
45 lines (37 loc) · 1.29 KB
/
Perf_Parser_Directives_Suggest.cs
File metadata and controls
45 lines (37 loc) · 1.29 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
// 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.Completions;
using System.Threading.Tasks;
using BenchmarkDotNet.Attributes;
namespace System.CommandLine.Benchmarks.CommandLine
{
/// <summary>
/// Measures the performance of [suggest] directive.
/// </summary>
[BenchmarkCategory(Categories.CommandLine)]
public class Perf_Parser_Directives_Suggest
{
public Command eatCommand;
[GlobalSetup]
public void Setup()
{
Option<string> fruitOption = new("--fruit");
fruitOption.CompletionSources.Add("apple", "banana", "cherry");
Option<string> vegetableOption = new("--vegetable");
vegetableOption.CompletionSources.Add("asparagus", "broccoli", "carrot");
eatCommand = new Command("eat")
{
fruitOption,
vegetableOption
};
}
[Params(
"[suggest:4] \"eat\"",
"[suggest:13] \"eat --fruit\""
)]
public string TestCmdArgs;
[Benchmark]
public Task InvokeSuggest()
=> eatCommand.Parse(TestCmdArgs).InvokeAsync();
}
}