Skip to content

Commit

Permalink
Cleanup: Redundancies in Symbol Declarations Issues in BenchmarkDotNet
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreyAkinshin committed Jul 28, 2018
1 parent a76f438 commit 2d06297
Show file tree
Hide file tree
Showing 93 changed files with 358 additions and 219 deletions.
4 changes: 2 additions & 2 deletions src/BenchmarkDotNet/Analysers/AnalyserBase.cs
Expand Up @@ -18,8 +18,8 @@ public IEnumerable<Conclusion> Analyse(Summary summary)
yield return conclusion;
}

protected virtual IEnumerable<Conclusion> AnalyseSummary(Summary summary) => Enumerable.Empty<Conclusion>();
protected virtual IEnumerable<Conclusion> AnalyseReport(BenchmarkReport report, Summary summary) => Enumerable.Empty<Conclusion>();
[PublicAPI] protected virtual IEnumerable<Conclusion> AnalyseSummary(Summary summary) => Enumerable.Empty<Conclusion>();
[PublicAPI] protected virtual IEnumerable<Conclusion> AnalyseReport(BenchmarkReport report, Summary summary) => Enumerable.Empty<Conclusion>();

protected Conclusion CreateHint(string message, [CanBeNull] BenchmarkReport report = null) => Conclusion.CreateHint(Id, message, report);
protected Conclusion CreateWarning(string message, [CanBeNull] BenchmarkReport report = null) => Conclusion.CreateWarning(Id, message, report);
Expand Down
5 changes: 3 additions & 2 deletions src/BenchmarkDotNet/Analysers/IAnalyser.cs
@@ -1,11 +1,12 @@
using System.Collections.Generic;
using BenchmarkDotNet.Reports;
using JetBrains.Annotations;

namespace BenchmarkDotNet.Analysers
{
public interface IAnalyser
{
string Id { get; }
IEnumerable<Conclusion> Analyse(Summary summary);
[PublicAPI] string Id { get; }
[PublicAPI] IEnumerable<Conclusion> Analyse(Summary summary);
}
}
2 changes: 2 additions & 0 deletions src/BenchmarkDotNet/Attributes/ArgumentsAttribute.cs
@@ -1,4 +1,5 @@
using System;
using JetBrains.Annotations;

namespace BenchmarkDotNet.Attributes
{
Expand All @@ -8,6 +9,7 @@ public class ArgumentsAttribute : Attribute
public object[] Values { get; }

// CLS-Compliant Code requires a constructor without an array in the argument list
[PublicAPI]
public ArgumentsAttribute()
{
Values = Array.Empty<object>();
Expand Down
3 changes: 2 additions & 1 deletion src/BenchmarkDotNet/Attributes/BenchmarkCategoryAttribute.cs
@@ -1,4 +1,5 @@
using System;
using JetBrains.Annotations;

namespace BenchmarkDotNet.Attributes
{
Expand All @@ -8,7 +9,7 @@ public class BenchmarkCategoryAttribute : Attribute
public string[] Categories { get; }

// CLS-Compliant Code requires a constructor without an array in the argument list
protected BenchmarkCategoryAttribute() { }
[PublicAPI] protected BenchmarkCategoryAttribute() { }

public BenchmarkCategoryAttribute(params string[] categories)
{
Expand Down
@@ -1,7 +1,9 @@
using BenchmarkDotNet.Columns;
using JetBrains.Annotations;

namespace BenchmarkDotNet.Attributes
{
[PublicAPI]
public class AllStatisticsColumnAttribute : ColumnConfigBaseAttribute
{
public AllStatisticsColumnAttribute() : base(StatisticColumn.AllStatistics)
Expand Down
@@ -1,13 +1,15 @@
using System;
using BenchmarkDotNet.Columns;
using BenchmarkDotNet.Configs;
using JetBrains.Annotations;

namespace BenchmarkDotNet.Attributes
{
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Assembly)]
public abstract class ColumnConfigBaseAttribute : Attribute, IConfigSource
{
// CLS-Compliant Code requires a constructor without an array in the argument list
[PublicAPI]
protected ColumnConfigBaseAttribute()
{
Config = ManualConfig.CreateEmpty();
Expand Down
@@ -1,8 +1,10 @@
using BenchmarkDotNet.Columns;
using BenchmarkDotNet.Mathematics;
using JetBrains.Annotations;

namespace BenchmarkDotNet.Attributes
{
[PublicAPI]
public class ConfidenceIntervalErrorColumnAttribute : ColumnConfigBaseAttribute
{
public ConfidenceIntervalErrorColumnAttribute(ConfidenceLevel level = ConfidenceLevel.L999) : base(StatisticColumn.CiError(level))
Expand Down
@@ -1,10 +1,12 @@
using BenchmarkDotNet.Columns;
using JetBrains.Annotations;

namespace BenchmarkDotNet.Attributes
{
/// <summary>
/// Add a column with the target method namespace.
/// </summary>
[PublicAPI]
public class NamespaceColumnAttribute : ColumnConfigBaseAttribute
{
public NamespaceColumnAttribute() : base(TargetMethodColumn.Namespace)
Expand Down
@@ -1,7 +1,9 @@
using BenchmarkDotNet.Columns;
using JetBrains.Annotations;

namespace BenchmarkDotNet.Attributes
{
[PublicAPI]
public class StdDevColumnAttribute : ColumnConfigBaseAttribute
{
public StdDevColumnAttribute() : base(StatisticColumn.StdDev)
Expand Down
@@ -1,7 +1,9 @@
using BenchmarkDotNet.Columns;
using JetBrains.Annotations;

namespace BenchmarkDotNet.Attributes
{
[PublicAPI]
public class StdErrorColumnAttribute : ColumnConfigBaseAttribute
{
public StdErrorColumnAttribute() : base(StatisticColumn.StdErr)
Expand Down
@@ -1,13 +1,15 @@
using System;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Exporters;
using JetBrains.Annotations;

namespace BenchmarkDotNet.Attributes
{
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Assembly)]
public class ExporterConfigBaseAttribute : Attribute, IConfigSource
{
// CLS-Compliant Code requires a constructor without an array in the argument list
[PublicAPI]
protected ExporterConfigBaseAttribute()
{
Config = ManualConfig.CreateEmpty();
Expand Down
@@ -1,7 +1,9 @@
using BenchmarkDotNet.Filters;
using JetBrains.Annotations;

namespace BenchmarkDotNet.Attributes
{
[PublicAPI]
public class AllCategoriesFilterAttribute : FilterConfigBaseAttribute
{
// CLS-Compliant Code requires a constructor without an array in the argument list
Expand Down
@@ -1,10 +1,12 @@
using BenchmarkDotNet.Filters;
using JetBrains.Annotations;

namespace BenchmarkDotNet.Attributes
{
public class AnyCategoriesFilterAttribute : FilterConfigBaseAttribute
{
// CLS-Compliant Code requires a constructor without an array in the argument list
[PublicAPI]
public AnyCategoriesFilterAttribute() { }

public AnyCategoriesFilterAttribute(params string[] targetCategories) : base(new AnyCategoriesFilter(targetCategories)) { }
Expand Down
@@ -1,4 +1,5 @@
using System;
using JetBrains.Annotations;

namespace BenchmarkDotNet.Attributes
{
Expand All @@ -8,7 +9,7 @@ public class GenericTypeArgumentsAttribute : Attribute
public Type[] GenericTypeArguments { get; }

// CLS-Compliant Code requires a constructor without an array in the argument list
public GenericTypeArgumentsAttribute() => GenericTypeArguments = Array.Empty<Type>();
[PublicAPI] public GenericTypeArgumentsAttribute() => GenericTypeArguments = Array.Empty<Type>();

public GenericTypeArgumentsAttribute(params Type[] genericTypeArguments) => GenericTypeArguments = genericTypeArguments;
}
Expand Down
2 changes: 2 additions & 0 deletions src/BenchmarkDotNet/Attributes/HardwareCountersAttribute.cs
@@ -1,13 +1,15 @@
using System;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Diagnosers;
using JetBrains.Annotations;

namespace BenchmarkDotNet.Attributes
{
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Assembly)]
public class HardwareCountersAttribute : Attribute, IConfigSource
{
// CLS-Compliant Code requires a constructor without an array in the argument list
[PublicAPI]
protected HardwareCountersAttribute()
{
Config = ManualConfig.CreateEmpty();
Expand Down
2 changes: 2 additions & 0 deletions src/BenchmarkDotNet/Attributes/Jobs/DryCoreRtJobAttribute.cs
@@ -1,7 +1,9 @@
using BenchmarkDotNet.Jobs;
using JetBrains.Annotations;

namespace BenchmarkDotNet.Attributes
{
[PublicAPI]
public class DryCoreRtJobAttribute : JobConfigBaseAttribute
{
public DryCoreRtJobAttribute() : base(Job.DryCoreRT) { }
Expand Down
2 changes: 2 additions & 0 deletions src/BenchmarkDotNet/Attributes/Jobs/JobConfigbaseAttribute.cs
@@ -1,13 +1,15 @@
using System;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Jobs;
using JetBrains.Annotations;

namespace BenchmarkDotNet.Attributes
{
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Assembly)]
public class JobConfigBaseAttribute : Attribute, IConfigSource
{
// CLS-Compliant Code requires a constructor which use only CLS-compliant types
[PublicAPI]
public JobConfigBaseAttribute() => Config = ManualConfig.CreateEmpty();

protected JobConfigBaseAttribute(Job job) => Config = ManualConfig.CreateEmpty().With(job);
Expand Down
2 changes: 2 additions & 0 deletions src/BenchmarkDotNet/Attributes/Jobs/RyuJitX86JobAttribute.cs
@@ -1,7 +1,9 @@
using BenchmarkDotNet.Jobs;
using JetBrains.Annotations;

namespace BenchmarkDotNet.Attributes
{
[PublicAPI]
public class RyuJitX86JobAttribute : JobConfigBaseAttribute
{
public RyuJitX86JobAttribute() : base(Job.RyuJitX86)
Expand Down
@@ -1,7 +1,9 @@
using BenchmarkDotNet.Jobs;
using JetBrains.Annotations;

namespace BenchmarkDotNet.Attributes
{
[PublicAPI]
public class VeryLongRunJobAttribute : JobConfigBaseAttribute
{
public VeryLongRunJobAttribute() : base(Job.VeryLongRun)
Expand Down
@@ -1,11 +1,13 @@
using BenchmarkDotNet.Jobs;
using JetBrains.Annotations;

namespace BenchmarkDotNet.Attributes
{
/// <summary>
/// Specifies if the overhead should be evaluated (Idle runs) and it's average value subtracted from every result.
/// True by default, very important for nano-benchmarks.
/// </summary>
[PublicAPI]
public class EvaluateOverheadAttribute : JobMutatorConfigBaseAttribute
{
public EvaluateOverheadAttribute(bool value = true) : base(Job.Default.WithEvaluateOverhead(value))
Expand Down
@@ -1,4 +1,5 @@
using BenchmarkDotNet.Jobs;
using JetBrains.Annotations;

namespace BenchmarkDotNet.Attributes
{
Expand All @@ -7,6 +8,7 @@ namespace BenchmarkDotNet.Attributes
/// <value>false: Does not run garbage collection concurrently.</value>
/// <value>true: Runs garbage collection concurrently. This is the default.</value>
/// </summary>
[PublicAPI]
public class GcConcurrentAttribute : JobMutatorConfigBaseAttribute
{
public GcConcurrentAttribute(bool value = true) : base(Job.Default.WithGcConcurrent(value))
Expand Down
2 changes: 2 additions & 0 deletions src/BenchmarkDotNet/Attributes/Mutators/GcForceAttribute.cs
@@ -1,4 +1,5 @@
using BenchmarkDotNet.Jobs;
using JetBrains.Annotations;

namespace BenchmarkDotNet.Attributes
{
Expand All @@ -7,6 +8,7 @@ namespace BenchmarkDotNet.Attributes
/// <value>false: Does not force garbage collection.</value>
/// <value>true: Forces full garbage collection after each benchmark invocation. This is the default.</value>
/// </summary>
[PublicAPI]
public class GcForceAttribute : JobMutatorConfigBaseAttribute
{
public GcForceAttribute(bool value = true) : base(Job.Default.WithGcForce(value))
Expand Down
2 changes: 2 additions & 0 deletions src/BenchmarkDotNet/Attributes/Mutators/GcServerAttribute.cs
@@ -1,4 +1,5 @@
using BenchmarkDotNet.Jobs;
using JetBrains.Annotations;

namespace BenchmarkDotNet.Attributes
{
Expand All @@ -7,6 +8,7 @@ namespace BenchmarkDotNet.Attributes
/// <value>false: Does not run server garbage collection. This is the default.</value>
/// <value>true: Runs server garbage collection.</value>
/// </summary>
[PublicAPI]
public class GcServerAttribute : JobMutatorConfigBaseAttribute
{
public GcServerAttribute(bool value = false) : base(Job.Default.WithGcServer(value))
Expand Down
@@ -1,11 +1,13 @@
using BenchmarkDotNet.Jobs;
using JetBrains.Annotations;

namespace BenchmarkDotNet.Attributes
{
/// <summary>
/// Invocation count in a single iteration.
/// Does exactly the same as InvocationCountAttribute, added to make porting from xunit-performance to BenchmarkDotNet easier
/// </summary>
[PublicAPI]
public class InnerIterationCountAttribute : JobMutatorConfigBaseAttribute
{
public InnerIterationCountAttribute(int invocationCount)
Expand Down
@@ -1,4 +1,5 @@
using BenchmarkDotNet.Jobs;
using JetBrains.Annotations;

namespace BenchmarkDotNet.Attributes
{
Expand All @@ -7,6 +8,7 @@ namespace BenchmarkDotNet.Attributes
/// If specified, <see cref="RunMode.IterationTime"/> will be ignored.
/// If specified, it must be a multiple of <see cref="RunMode.UnrollFactor"/>.
/// </summary>
[PublicAPI]
public class InvocationCountAttribute : JobMutatorConfigBaseAttribute
{
public InvocationCountAttribute(int invocationCount, int unrollFactor = 1)
Expand Down
@@ -1,4 +1,5 @@
using BenchmarkDotNet.Jobs;
using JetBrains.Annotations;

namespace BenchmarkDotNet.Attributes
{
Expand All @@ -7,6 +8,7 @@ namespace BenchmarkDotNet.Attributes
/// If specified, <see cref="RunMode.MinIterationCount"/> will be ignored.
/// If specified, <see cref="RunMode.MaxIterationCount"/> will be ignored.
/// </summary>
[PublicAPI]
public class IterationCountAttribute : JobMutatorConfigBaseAttribute
{
public IterationCountAttribute(int targetIterationCount) : base(Job.Default.WithIterationCount(targetIterationCount))
Expand Down
@@ -1,12 +1,14 @@
using BenchmarkDotNet.Horology;
using BenchmarkDotNet.Jobs;
using JetBrains.Annotations;

namespace BenchmarkDotNet.Attributes
{
/// <summary>
/// Desired time of execution of an iteration. Used by Pilot stage to estimate the number of invocations per iteration.
/// The default value is 500 milliseconds.
/// </summary>
[PublicAPI]
public class IterationTimeAttribute : JobMutatorConfigBaseAttribute
{
public IterationTimeAttribute(double milliseconds) : base(Job.Default.WithIterationTime(TimeInterval.FromMilliseconds(milliseconds)))
Expand Down
@@ -1,13 +1,15 @@
using System;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Jobs;
using JetBrains.Annotations;

namespace BenchmarkDotNet.Attributes
{
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] // users must not be able to define given mutator attribute more than once per type
public class JobMutatorConfigBaseAttribute : Attribute, IConfigSource
{
// CLS-Compliant Code requires a constructor which use only CLS-compliant types
[PublicAPI]
public JobMutatorConfigBaseAttribute() => Config = ManualConfig.CreateEmpty();

protected JobMutatorConfigBaseAttribute(Job job) => Config = ManualConfig.CreateEmpty().With(job.AsMutator());
Expand Down
@@ -1,5 +1,6 @@
using BenchmarkDotNet.Horology;
using BenchmarkDotNet.Jobs;
using JetBrains.Annotations;

namespace BenchmarkDotNet.Attributes
{
Expand All @@ -8,6 +9,7 @@ namespace BenchmarkDotNet.Attributes
/// Doesn't have a default value.
/// <remarks>If <see cref="AccuracyMode.MaxRelativeError"/> is also provided, the smallest value is used as stop criteria.</remarks>
/// </summary>
[PublicAPI]
public class MaxAbsoluteErrorAttribute : JobMutatorConfigBaseAttribute
{
public MaxAbsoluteErrorAttribute(double nanoseconds) : base(Job.Default.WithMaxAbsoluteError(TimeInterval.FromNanoseconds(nanoseconds)))
Expand Down
@@ -1,4 +1,5 @@
using BenchmarkDotNet.Jobs;
using JetBrains.Annotations;

namespace BenchmarkDotNet.Attributes
{
Expand All @@ -7,6 +8,7 @@ namespace BenchmarkDotNet.Attributes
/// The default value is 0.02.
/// <remarks>If <see cref="AccuracyMode.MaxAbsoluteError"/> is also provided, the smallest value is used as stop criteria.</remarks>
/// </summary>
[PublicAPI]
public class MaxRelativeErrorAttribute : JobMutatorConfigBaseAttribute
{
public MaxRelativeErrorAttribute(double maxRelativeError) : base(Job.Default.WithMaxRelativeError(maxRelativeError))
Expand Down

0 comments on commit 2d06297

Please sign in to comment.