Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions sandbox/CliFrameworkBenchmark/Benchmark.cs
Original file line number Diff line number Diff line change
@@ -1,23 +1,15 @@
// This benchmark project is based on CliFx.Benchmarks.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.editorconfig is recently modified to use utf8-bom.
It need to apply this rule to all cs files by dotnet format command on another PR.

// This benchmark project is based on CliFx.Benchmarks.
// https://github.com/Tyrrrz/CliFx/tree/master/CliFx.Benchmarks/

using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Engines;
using BenchmarkDotNet.Order;
using CliFx;
using Cocona.Benchmark.External.Commands;
using CommandLine;
using ConsoleAppFramework;
using PowerArgs;
using Spectre.Console.Cli;
using System.ComponentModel.DataAnnotations.Schema;
using BenchmarkDotNet.Columns;

namespace Cocona.Benchmark.External;

// use ColdStart strategy to measure startup time evaluation
[SimpleJob(RunStrategy.ColdStart, launchCount: 1, warmupCount: 0, iterationCount: 1, invocationCount: 1)]
[MemoryDiagnoser]
[Orderer(SummaryOrderPolicy.FastestToSlowest)]
public class Benchmark
{
Expand Down
10 changes: 5 additions & 5 deletions sandbox/CliFrameworkBenchmark/CliFrameworkBenchmark.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
<PackageReference Include="CliFx" Version="2.3.5" />
<PackageReference Include="BenchmarkDotNet" Version="0.15.2" />
<PackageReference Include="CliFx" Version="2.3.6" />
<PackageReference Include="clipr" Version="1.6.1" />
<PackageReference Include="Cocona" Version="2.2.0" />
<PackageReference Include="Cocona.Lite" Version="2.2.0" />
Expand All @@ -25,9 +25,9 @@
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="4.1.1" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0" />
<PackageReference Include="PowerArgs" Version="4.0.3" />
<PackageReference Include="Spectre.Console.Cli" Version="0.49.1" />
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
<PackageReference Include="System.CommandLine.NamingConventionBinder" Version="2.0.0-beta4.22272.1" />
<PackageReference Include="Spectre.Console.Cli" Version="0.50.0" />
<PackageReference Include="System.CommandLine" Version="2.0.0-beta5.25306.1" />
<PackageReference Include="System.CommandLine.NamingConventionBinder" Version="2.0.0-beta5.25306.1" />
</ItemGroup>


Expand Down
32 changes: 22 additions & 10 deletions sandbox/CliFrameworkBenchmark/Commands/SystemCommandLineCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,37 @@ public static int Execute(string[] args)
{
var command = new RootCommand
{
new Option<string?>(new[] {"--str", "-s"}),
new Option<int>(new[] {"--int", "-i"}),
new Option<bool>(new[] {"--bool", "-b"}),
new Option<string?>("--str", ["-s"]),
new Option<int>("--int", ["-i"]),
new Option<bool>("--bool", ["-b"]),
};

command.Handler = CommandHandler.Create(ExecuteHandler);
return command.Invoke(args);
command.SetAction(parseResult =>
{
var handler = CommandHandler.Create(ExecuteHandler);
return handler.InvokeAsync(parseResult);
});

ParseResult parseResult = command.Parse(args);
return parseResult.Invoke();
}

public static Task<int> ExecuteAsync(string[] args)
{
var command = new RootCommand
{
new Option<string?>(new[] {"--str", "-s"}),
new Option<int>(new[] {"--int", "-i"}),
new Option<bool>(new[] {"--bool", "-b"}),
new Option<string?>("--str", ["-s"]),
new Option<int>("--int", ["-i"]),
new Option<bool>("--bool", ["-b"]),
};

command.Handler = CommandHandler.Create(ExecuteHandler);
return command.InvokeAsync(args);
command.SetAction((parseResult, cancellationToken) =>
{
var handler = CommandHandler.Create(ExecuteHandler);
return handler.InvokeAsync(parseResult);
});

ParseResult parseResult = command.Parse(args);
return parseResult.InvokeAsync();
}
}
22 changes: 21 additions & 1 deletion sandbox/CliFrameworkBenchmark/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@
// https://github.com/Tyrrrz/CliFx/tree/master/CliFx.Benchmarks/

using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Diagnosers;
using BenchmarkDotNet.Engines;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Reports;
using BenchmarkDotNet.Running;
using BenchmarkDotNet.Toolchains.CsProj;
using Perfolizer.Horology;

namespace Cocona.Benchmark.External;
Expand All @@ -12,6 +16,22 @@ class Program
{
static void Main(string[] args)
{
BenchmarkRunner.Run<Benchmark>(DefaultConfig.Instance.WithSummaryStyle(SummaryStyle.Default.WithTimeUnit(TimeUnit.Millisecond)), args);
var config = DefaultConfig.Instance
.WithSummaryStyle(SummaryStyle.Default
.WithTimeUnit(TimeUnit.Millisecond));

config.AddDiagnoser(MemoryDiagnoser.Default);
config.AddDiagnoser(new ThreadingDiagnoser(new ThreadingDiagnoserConfig(displayLockContentionWhenZero: false, displayCompletedWorkItemCountWhenZero: false)));

config.AddJob(Job.Default
.WithStrategy(RunStrategy.ColdStart)
.WithLaunchCount(1)
.WithWarmupCount(0)
.WithIterationCount(1)
.WithInvocationCount(1)
.WithToolchain(CsProjCoreToolchain.NetCoreApp80)
.DontEnforcePowerPlan());

BenchmarkRunner.Run<Benchmark>(config, args);
}
}
4 changes: 2 additions & 2 deletions sandbox/GeneratorSandbox/GeneratorSandbox.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

<ItemGroup>
<!--<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="9.0.0" />-->
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="9.0.0" />-->
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.6" />
<!--<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.0" />-->
<!--<PackageReference Include="ZLogger" Version="2.5.9" />-->
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/ConsoleAppFramework/ConsoleAppFramework.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<!-- Roslyn for .NET 8 / C# 12 -->
<!-- https://learn.microsoft.com/en-us/visualstudio/extensibility/roslyn-version-support -->
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.8.0" />
<PackageReference Include="PolySharp" Version="1.14.1">
<PackageReference Include="PolySharp" Version="1.15.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@

<ItemGroup>
<PackageReference Include="Shouldly" Version="4.3.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.12.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
<PackageReference Include="xunit.v3" Version="1.1.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.2">
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.14.0" />
<PackageReference Include="xunit.v3" Version="2.0.3" />
</ItemGroup>

<!-- Following settings will be removed -->
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down