-
Couldn't load subscription status.
- Fork 840
Add common BDN configs #303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| // Copyright (c) .NET Foundation. All rights reserved. | ||
| // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
|
||
| using System; | ||
| using System.Linq; | ||
| using System.Reflection; | ||
| using BenchmarkDotNet.Attributes; | ||
| using BenchmarkDotNet.Running; | ||
| using BenchmarkDotNet.Configs; | ||
| using BenchmarkDotNet.Jobs; | ||
| using BenchmarkDotNet.Toolchains.InProcess; | ||
|
|
||
| namespace BenchmarkDotNet.Attributes | ||
| { | ||
| [AttributeUsage(AttributeTargets.Class | AttributeTargets.Assembly)] | ||
| public class AspNetCoreBenchmarkAttribute : Attribute, IConfigSource | ||
| { | ||
| public static bool UseValidationConfig { get; set; } | ||
|
|
||
| public Type ConfigType { get;set; } | ||
|
||
| public Type ValidationConfigType { get;set; } | ||
|
|
||
| public AspNetCoreBenchmarkAttribute() : this(typeof(CoreConfig)) | ||
| { | ||
| } | ||
|
|
||
| public AspNetCoreBenchmarkAttribute(Type configType) : this(configType, typeof(CoreValidationConfig)) | ||
| { | ||
| } | ||
|
|
||
| public AspNetCoreBenchmarkAttribute(Type configType, Type validationConfigType) | ||
| { | ||
| ConfigType = configType; | ||
| ValidationConfigType = validationConfigType; | ||
| } | ||
|
|
||
| public IConfig Config => (IConfig) Activator.CreateInstance(UseValidationConfig ? ValidationConfigType : ConfigType, Array.Empty<object>()); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| // Copyright (c) .NET Foundation. All rights reserved. | ||
| // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
|
||
| using BenchmarkDotNet.Columns; | ||
| using BenchmarkDotNet.Configs; | ||
| using BenchmarkDotNet.Diagnosers; | ||
| using BenchmarkDotNet.Engines; | ||
| using BenchmarkDotNet.Exporters; | ||
| using BenchmarkDotNet.Jobs; | ||
| using BenchmarkDotNet.Loggers; | ||
| using BenchmarkDotNet.Toolchains.CsProj; | ||
| using BenchmarkDotNet.Toolchains.DotNetCli; | ||
| using BenchmarkDotNet.Validators; | ||
|
|
||
| namespace BenchmarkDotNet.Attributes | ||
| { | ||
| public class CoreConfig : ManualConfig | ||
|
||
| { | ||
| public CoreConfig() | ||
| { | ||
| Add(ConsoleLogger.Default); | ||
| Add(MarkdownExporter.GitHub); | ||
|
|
||
| Add(MemoryDiagnoser.Default); | ||
| Add(StatisticColumn.OperationsPerSecond); | ||
|
|
||
| Add(JitOptimizationsValidator.FailOnError); | ||
|
|
||
| Add(Job.Core | ||
| .With(CsProjCoreToolchain.From(NetCoreAppSettings.NetCoreApp21)) | ||
| .WithRemoveOutliers(false) | ||
| .With(new GcMode { Server = true }) | ||
| .With(RunStrategy.Throughput) | ||
| .WithLaunchCount(3) | ||
| .WithWarmupCount(5) | ||
| .WithTargetCount(10)); | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| // Copyright (c) .NET Foundation. All rights reserved. | ||
| // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
|
||
| using System; | ||
| using System.Linq; | ||
| using System.Reflection; | ||
| using BenchmarkDotNet.Attributes; | ||
| using BenchmarkDotNet.Running; | ||
| using BenchmarkDotNet.Configs; | ||
| using BenchmarkDotNet.Jobs; | ||
| using BenchmarkDotNet.Loggers; | ||
| using BenchmarkDotNet.Toolchains.InProcess; | ||
|
|
||
| namespace BenchmarkDotNet.Attributes | ||
| { | ||
| public class CoreValidationConfig : ManualConfig | ||
| { | ||
| public CoreValidationConfig() | ||
| { | ||
| Add(ConsoleLogger.Default); | ||
|
|
||
| Add(Job.Dry.With(InProcessToolchain.Instance)); | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,13 +14,17 @@ | |
|
|
||
| namespace Microsoft.AspNetCore.BenchmarkDotNet.Runner | ||
| { | ||
| class Program | ||
| partial class Program | ||
| { | ||
| private static TextWriter _standardOutput; | ||
| private static StringBuilder _standardOutputText; | ||
|
|
||
| static partial void BeforeMain(string[] args); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice |
||
|
|
||
| private static int Main(string[] args) | ||
| { | ||
| BeforeMain(args); | ||
|
|
||
| CheckValidate(ref args); | ||
| var summaries = BenchmarkSwitcher.FromAssembly(typeof(Program).GetTypeInfo().Assembly) | ||
| .Run(args, ManualConfig.CreateEmpty()); | ||
|
|
@@ -65,15 +69,10 @@ private static int Fail(object o, string message) | |
| private static void CheckValidate(ref string[] args) | ||
| { | ||
| var argsList = args.ToList(); | ||
| if (argsList.Remove("--validate")) | ||
| { | ||
| SuppressConsole(); | ||
| ParameterizedJobConfigAttribute.Job = Job.Dry; | ||
| } | ||
| else if (argsList.Remove("--validate-fast")) | ||
| if (argsList.Remove("--validate") || argsList.Remove("--validate-fast")) | ||
| { | ||
| SuppressConsole(); | ||
| ParameterizedJobConfigAttribute.Job = Job.Dry.With(InProcessToolchain.Instance); | ||
| AspNetCoreBenchmarkAttribute.UseValidationConfig = true; | ||
| } | ||
|
|
||
| args = argsList.ToArray(); | ||
|
|
@@ -86,4 +85,4 @@ private static void SuppressConsole() | |
| Console.SetOut(new StringWriter(_standardOutputText)); | ||
| } | ||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make these types
internal