-
Notifications
You must be signed in to change notification settings - Fork 417
Expand file tree
/
Copy pathPerf_Parser_CustomScenarios.cs
More file actions
34 lines (29 loc) · 1.26 KB
/
Perf_Parser_CustomScenarios.cs
File metadata and controls
34 lines (29 loc) · 1.26 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
// 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.Parsing;
using BenchmarkDotNet.Attributes;
namespace System.CommandLine.Benchmarks.CommandLine
{
/// <summary>
/// Measures the performance of <see cref="CliParser"/> for custom scenarios.
/// </summary>
[BenchmarkCategory(Categories.CommandLine)]
public class Perf_Parser_CustomScenarios
{
private string _testSymbolsAsString;
private Command _rootCommand;
[GlobalSetup(Target = nameof(OneOptWithNestedCommand_Parse))]
public void SetupOneOptWithNestedCommand()
{
_rootCommand = new Command("root_command");
var nestedCommand = new Command("nested_command");
var option = new Option<int>("-opt1") { DefaultValueFactory = (_) => 123 };
nestedCommand.Options.Add(option);
_rootCommand.Subcommands.Add(nestedCommand);
_testSymbolsAsString = "root_command nested_command -opt1 321";
}
[Benchmark]
public ParseResult OneOptWithNestedCommand_Parse()
=> _rootCommand.Parse(_testSymbolsAsString);
}
}