Attribute Config style, fixes #166
This commit is contained in:
Родитель
664c647481
Коммит
c9e8021755
|
@ -1,22 +1,11 @@
|
|||
using System;
|
||||
using System.Security.Cryptography;
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using BenchmarkDotNet.Configs;
|
||||
using BenchmarkDotNet.Jobs;
|
||||
using BenchmarkDotNet.Attributes.Jobs;
|
||||
|
||||
namespace BenchmarkDotNet.Samples.Algorithms
|
||||
{
|
||||
internal class AllWindowsRuntimesConfig : ManualConfig
|
||||
{
|
||||
public AllWindowsRuntimesConfig()
|
||||
{
|
||||
Add(Job.Default.With(Runtime.Clr));
|
||||
Add(Job.Default.With(Runtime.Mono));
|
||||
Add(Job.Default.With(Runtime.Core));
|
||||
}
|
||||
}
|
||||
|
||||
[Config(typeof(AllWindowsRuntimesConfig))]
|
||||
{
|
||||
[ClrJob, MonoJob, CoreJob]
|
||||
public class Algo_Md5VsSha256
|
||||
{
|
||||
private const int N = 10000;
|
||||
|
|
|
@ -1,21 +1,12 @@
|
|||
using BenchmarkDotNet.Jobs;
|
||||
using System;
|
||||
using System;
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using BenchmarkDotNet.Configs;
|
||||
using BenchmarkDotNet.Attributes.Jobs;
|
||||
|
||||
namespace BenchmarkDotNet.Samples.Algorithms
|
||||
{
|
||||
[Config(typeof(Config))]
|
||||
[LegacyJitX64Job, RyuJitX64Job]
|
||||
public class Algo_MostSignificantBit
|
||||
{
|
||||
private class Config : ManualConfig
|
||||
{
|
||||
public Config()
|
||||
{
|
||||
Add(Job.LegacyJitX64, Job.RyuJitX64);
|
||||
}
|
||||
}
|
||||
|
||||
private const int N = 4001;
|
||||
private readonly int[] numbers;
|
||||
private readonly Random random = new Random(42);
|
||||
|
|
|
@ -1,20 +1,11 @@
|
|||
using BenchmarkDotNet.Attributes;
|
||||
using BenchmarkDotNet.Configs;
|
||||
using BenchmarkDotNet.Jobs;
|
||||
using BenchmarkDotNet.Attributes.Jobs;
|
||||
|
||||
namespace BenchmarkDotNet.Samples.CPU
|
||||
{
|
||||
[Config(typeof(Config))]
|
||||
[RyuJitX64Job]
|
||||
public class Cpu_Atomics
|
||||
{
|
||||
private class Config : ManualConfig
|
||||
{
|
||||
public Config()
|
||||
{
|
||||
Add(Job.RyuJitX64);
|
||||
}
|
||||
}
|
||||
|
||||
private int a;
|
||||
private object syncRoot = new object();
|
||||
|
||||
|
|
|
@ -1,22 +1,13 @@
|
|||
using System;
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using BenchmarkDotNet.Configs;
|
||||
using BenchmarkDotNet.Jobs;
|
||||
using BenchmarkDotNet.Attributes.Jobs;
|
||||
|
||||
namespace BenchmarkDotNet.Samples.CPU
|
||||
{
|
||||
// See http://stackoverflow.com/questions/11227809/why-is-processing-a-sorted-array-faster-than-an-unsorted-array/11227902
|
||||
[Config(typeof(Config))]
|
||||
[LegacyJitX86Job]
|
||||
public class Cpu_BranchPerdictor
|
||||
{
|
||||
private class Config : ManualConfig
|
||||
{
|
||||
public Config()
|
||||
{
|
||||
Add(Job.LegacyJitX86);
|
||||
}
|
||||
}
|
||||
|
||||
private const int N = 32767;
|
||||
private readonly int[] sorted, unsorted;
|
||||
|
||||
|
|
|
@ -1,21 +1,12 @@
|
|||
using BenchmarkDotNet.Attributes;
|
||||
using BenchmarkDotNet.Configs;
|
||||
using BenchmarkDotNet.Jobs;
|
||||
using BenchmarkDotNet.Attributes.Jobs;
|
||||
|
||||
namespace BenchmarkDotNet.Samples.CPU
|
||||
{
|
||||
// See http://en.wikipedia.org/wiki/Instruction-level_parallelism
|
||||
[Config(typeof(Config))]
|
||||
[AllJitsJob]
|
||||
public class Cpu_Ilp_Inc
|
||||
{
|
||||
private class Config : ManualConfig
|
||||
{
|
||||
public Config()
|
||||
{
|
||||
Add(Job.LegacyJitX86, Job.LegacyJitX64, Job.RyuJitX64);
|
||||
}
|
||||
}
|
||||
|
||||
private double a, b, c, d;
|
||||
|
||||
[Benchmark(OperationsPerInvoke = 4)]
|
||||
|
|
|
@ -1,21 +1,12 @@
|
|||
using BenchmarkDotNet.Attributes;
|
||||
using BenchmarkDotNet.Configs;
|
||||
using BenchmarkDotNet.Jobs;
|
||||
using BenchmarkDotNet.Attributes.Jobs;
|
||||
|
||||
namespace BenchmarkDotNet.Samples.CPU
|
||||
{
|
||||
// See: https://github.com/dotnet/coreclr/issues/993
|
||||
[Config(typeof(Config))]
|
||||
[LegacyJitX64Job, RyuJitX64Job]
|
||||
public class Cpu_Ilp_RyuJit
|
||||
{
|
||||
private class Config : ManualConfig
|
||||
{
|
||||
public Config()
|
||||
{
|
||||
Add(Job.LegacyJitX64, Job.RyuJitX64);
|
||||
}
|
||||
}
|
||||
|
||||
private double[] x = new double[11];
|
||||
|
||||
[Benchmark]
|
||||
|
|
|
@ -1,21 +1,12 @@
|
|||
using BenchmarkDotNet.Attributes;
|
||||
using BenchmarkDotNet.Configs;
|
||||
using BenchmarkDotNet.Jobs;
|
||||
using BenchmarkDotNet.Attributes.Jobs;
|
||||
|
||||
namespace BenchmarkDotNet.Samples.CPU
|
||||
{
|
||||
// See http://en.wikipedia.org/wiki/Instruction-level_parallelism
|
||||
[Config(typeof(Config))]
|
||||
[AllJitsJob]
|
||||
public class Cpu_Ilp_VsBce
|
||||
{
|
||||
private class Config : ManualConfig
|
||||
{
|
||||
public Config()
|
||||
{
|
||||
Add(Job.LegacyJitX86, Job.LegacyJitX64, Job.RyuJitX64);
|
||||
}
|
||||
}
|
||||
|
||||
private int[] a = new int[4];
|
||||
|
||||
[Benchmark(OperationsPerInvoke = 4)]
|
||||
|
|
|
@ -1,21 +1,14 @@
|
|||
using BenchmarkDotNet.Attributes;
|
||||
using BenchmarkDotNet.Attributes.Jobs;
|
||||
using BenchmarkDotNet.Configs;
|
||||
using BenchmarkDotNet.Jobs;
|
||||
|
||||
namespace BenchmarkDotNet.Samples.CPU
|
||||
{
|
||||
// See http://en.wikipedia.org/wiki/Matrix_multiplication_algorithm#Cache_behavior
|
||||
[Config(typeof(Config))]
|
||||
[AllJitsJob]
|
||||
public class Cpu_MatrixMultiplication
|
||||
{
|
||||
private class Config : ManualConfig
|
||||
{
|
||||
public Config()
|
||||
{
|
||||
Add(Job.LegacyJitX86, Job.LegacyJitX64, Job.RyuJitX64);
|
||||
}
|
||||
}
|
||||
|
||||
private const int N = 512;
|
||||
private readonly double[,] a = new double[N, N];
|
||||
private readonly double[,] b = new double[N, N];
|
||||
|
|
|
@ -1,21 +1,12 @@
|
|||
using System.Diagnostics;
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using BenchmarkDotNet.Configs;
|
||||
using BenchmarkDotNet.Jobs;
|
||||
using BenchmarkDotNet.Attributes.Jobs;
|
||||
|
||||
namespace BenchmarkDotNet.Samples.Framework
|
||||
{
|
||||
[Config(typeof(Config))]
|
||||
[ClrJob, MonoJob]
|
||||
public class Framework_Stopwatch
|
||||
{
|
||||
private class Config : ManualConfig
|
||||
{
|
||||
public Config()
|
||||
{
|
||||
Add(Job.Clr, Job.Mono);
|
||||
}
|
||||
}
|
||||
|
||||
[Benchmark]
|
||||
public long Latency()
|
||||
{
|
||||
|
|
|
@ -1,21 +1,12 @@
|
|||
using BenchmarkDotNet.Attributes;
|
||||
using BenchmarkDotNet.Configs;
|
||||
using BenchmarkDotNet.Jobs;
|
||||
using BenchmarkDotNet.Attributes.Jobs;
|
||||
|
||||
namespace BenchmarkDotNet.Samples.IL
|
||||
{
|
||||
// See: http://codeblog.jonskeet.uk/2014/07/16/micro-optimization-the-surprising-inefficiency-of-readonly-fields/
|
||||
[Config(typeof(Config))]
|
||||
[AllJitsJob]
|
||||
public class IL_ReadonlyFields
|
||||
{
|
||||
private class Config : ManualConfig
|
||||
{
|
||||
public Config()
|
||||
{
|
||||
Add(Job.LegacyJitX86, Job.LegacyJitX64, Job.RyuJitX64);
|
||||
}
|
||||
}
|
||||
|
||||
public struct Int256
|
||||
{
|
||||
private readonly long bits0, bits1, bits2, bits3;
|
||||
|
|
|
@ -1,20 +1,11 @@
|
|||
using BenchmarkDotNet.Attributes;
|
||||
using BenchmarkDotNet.Configs;
|
||||
using BenchmarkDotNet.Jobs;
|
||||
using BenchmarkDotNet.Attributes.Jobs;
|
||||
|
||||
namespace BenchmarkDotNet.Samples.IL
|
||||
{
|
||||
[Config(typeof(Config))]
|
||||
[LegacyJitX64Job]
|
||||
public class IL_Switch
|
||||
{
|
||||
private class Config : ManualConfig
|
||||
{
|
||||
public Config()
|
||||
{
|
||||
Add(Job.LegacyJitX64);
|
||||
}
|
||||
}
|
||||
|
||||
private int x = 7, y = 7000;
|
||||
|
||||
[Benchmark]
|
||||
|
|
|
@ -1,20 +1,11 @@
|
|||
using BenchmarkDotNet.Attributes;
|
||||
using BenchmarkDotNet.Configs;
|
||||
using BenchmarkDotNet.Jobs;
|
||||
using BenchmarkDotNet.Attributes.Jobs;
|
||||
|
||||
namespace BenchmarkDotNet.Samples.JIT
|
||||
{
|
||||
[Config(typeof(Config))]
|
||||
[AllJitsJob]
|
||||
public class Jit_AsVsCast
|
||||
{
|
||||
private class Config : ManualConfig
|
||||
{
|
||||
public Config()
|
||||
{
|
||||
Add(Job.AllJits);
|
||||
}
|
||||
}
|
||||
|
||||
public class Foo
|
||||
{
|
||||
}
|
||||
|
|
|
@ -1,19 +1,11 @@
|
|||
using BenchmarkDotNet.Attributes;
|
||||
using BenchmarkDotNet.Configs;
|
||||
using BenchmarkDotNet.Jobs;
|
||||
using BenchmarkDotNet.Attributes.Jobs;
|
||||
|
||||
namespace BenchmarkDotNet.Samples.JIT
|
||||
{
|
||||
[Config(typeof(Config))]
|
||||
[AllJitsJob]
|
||||
public class Jit_Bce
|
||||
{
|
||||
private class Config : ManualConfig
|
||||
{
|
||||
public Config()
|
||||
{
|
||||
Add(Job.AllJits);
|
||||
}
|
||||
}
|
||||
private const int N = 11;
|
||||
private int[] x = new int[N];
|
||||
|
||||
|
|
|
@ -1,21 +1,12 @@
|
|||
using BenchmarkDotNet.Jobs;
|
||||
using System;
|
||||
using System;
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using BenchmarkDotNet.Configs;
|
||||
using BenchmarkDotNet.Attributes.Jobs;
|
||||
|
||||
namespace BenchmarkDotNet.Samples.JIT
|
||||
{
|
||||
[Config(typeof(Config))]
|
||||
[LegacyJitX64Job, RyuJitX64Job]
|
||||
public class Jit_BoolToInt
|
||||
{
|
||||
private class Config : ManualConfig
|
||||
{
|
||||
public Config()
|
||||
{
|
||||
Add(Job.LegacyJitX64, Job.RyuJitX64);
|
||||
}
|
||||
}
|
||||
|
||||
private bool p1, p2, p3, p4, p5, p6;
|
||||
public int q1, q2, q3, q4, q5, q6;
|
||||
|
||||
|
|
|
@ -1,23 +1,16 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using BenchmarkDotNet.Attributes.Jobs;
|
||||
using BenchmarkDotNet.Configs;
|
||||
using BenchmarkDotNet.Jobs;
|
||||
|
||||
namespace BenchmarkDotNet.Samples.JIT
|
||||
{
|
||||
// See: https://alexandrnikitin.github.io/blog/dotnet-generics-under-the-hood/
|
||||
[Config(typeof(Config))]
|
||||
[AllJitsJob]
|
||||
public class Jit_GenericsMethod
|
||||
{
|
||||
private class Config : ManualConfig
|
||||
{
|
||||
public Config()
|
||||
{
|
||||
Add(Job.AllJits);
|
||||
}
|
||||
}
|
||||
|
||||
private class BaseClass<T>
|
||||
{
|
||||
private List<T> list = new List<T>();
|
||||
|
|
|
@ -1,22 +1,13 @@
|
|||
using BenchmarkDotNet.Attributes;
|
||||
using BenchmarkDotNet.Configs;
|
||||
using BenchmarkDotNet.Jobs;
|
||||
using BenchmarkDotNet.Attributes.Jobs;
|
||||
|
||||
namespace BenchmarkDotNet.Samples.JIT
|
||||
{
|
||||
// See http://en.wikipedia.org/wiki/Inline_expansion
|
||||
// See http://aakinshin.net/en/blog/dotnet/inlining-and-starg/
|
||||
[Config(typeof(Config))]
|
||||
[AllJitsJob]
|
||||
public class Jit_Inlining
|
||||
{
|
||||
private class Config : ManualConfig
|
||||
{
|
||||
public Config()
|
||||
{
|
||||
Add(Job.AllJits);
|
||||
}
|
||||
}
|
||||
|
||||
[Benchmark]
|
||||
public int Calc()
|
||||
{
|
||||
|
|
|
@ -1,19 +1,11 @@
|
|||
using BenchmarkDotNet.Attributes;
|
||||
using BenchmarkDotNet.Configs;
|
||||
using BenchmarkDotNet.Jobs;
|
||||
using BenchmarkDotNet.Attributes.Jobs;
|
||||
|
||||
namespace BenchmarkDotNet.Samples.JIT
|
||||
{
|
||||
[LegacyJitX86Job, LegacyJitX64Job]
|
||||
public class Jit_InterfaceMethod
|
||||
{
|
||||
private class Config : ManualConfig
|
||||
{
|
||||
public Config()
|
||||
{
|
||||
Add(Job.LegacyJitX86, Job.LegacyJitX64);
|
||||
}
|
||||
}
|
||||
|
||||
private interface IFoo
|
||||
{
|
||||
double Inc(double x);
|
||||
|
|
|
@ -1,20 +1,11 @@
|
|||
using BenchmarkDotNet.Attributes;
|
||||
using BenchmarkDotNet.Configs;
|
||||
using BenchmarkDotNet.Jobs;
|
||||
using BenchmarkDotNet.Attributes.Jobs;
|
||||
|
||||
namespace BenchmarkDotNet.Samples.JIT
|
||||
{
|
||||
[Config(typeof(Config))]
|
||||
[AllJitsJob]
|
||||
public class Jit_LoopUnrolling
|
||||
{
|
||||
private class Config : ManualConfig
|
||||
{
|
||||
public Config()
|
||||
{
|
||||
Add(Job.AllJits);
|
||||
}
|
||||
}
|
||||
|
||||
[Benchmark]
|
||||
public int Sum()
|
||||
{
|
||||
|
|
|
@ -1,22 +1,13 @@
|
|||
using System.Diagnostics;
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using BenchmarkDotNet.Configs;
|
||||
using BenchmarkDotNet.Jobs;
|
||||
using BenchmarkDotNet.Attributes.Jobs;
|
||||
|
||||
namespace BenchmarkDotNet.Samples.JIT
|
||||
{
|
||||
// See http://stackoverflow.com/questions/32114308/weird-performance-increase-in-simple-benchmark
|
||||
[Config(typeof(Config))]
|
||||
[LegacyJitX86Job]
|
||||
public class Jit_RegistersVsStack
|
||||
{
|
||||
private class Config : ManualConfig
|
||||
{
|
||||
public Config()
|
||||
{
|
||||
Add(Job.LegacyJitX86);
|
||||
}
|
||||
}
|
||||
|
||||
[Params(false, true)]
|
||||
public bool CallStopwatchTimestamp { get; set; }
|
||||
|
||||
|
|
|
@ -1,22 +1,15 @@
|
|||
using System;
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using BenchmarkDotNet.Attributes.Jobs;
|
||||
using BenchmarkDotNet.Configs;
|
||||
using BenchmarkDotNet.Jobs;
|
||||
|
||||
namespace BenchmarkDotNet.Samples.Other
|
||||
{
|
||||
// See: http://stackoverflow.com/q/8497018/974487
|
||||
[Config(typeof(Config))]
|
||||
[AllJitsJob]
|
||||
public class Array_AccessNormalRefUnsafe
|
||||
{
|
||||
private class Config : ManualConfig
|
||||
{
|
||||
public Config()
|
||||
{
|
||||
Add(Job.AllJits);
|
||||
}
|
||||
}
|
||||
|
||||
private const int Iterations = 111;
|
||||
private static float[] buffer = new float[1024 * 1024 * 100];
|
||||
private static readonly int Len = buffer.Length;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
using System;
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using BenchmarkDotNet.Configs;
|
||||
using BenchmarkDotNet.Jobs;
|
||||
using BenchmarkDotNet.Attributes.Jobs;
|
||||
|
||||
namespace BenchmarkDotNet.Samples.Other
|
||||
{
|
||||
|
@ -9,16 +8,9 @@ namespace BenchmarkDotNet.Samples.Other
|
|||
// LegacyJit x86: fsqrt (FPU)
|
||||
// LegacyJit x64: sqrtsd (SSE2)
|
||||
// RyuJIT x64: vsqrtsd (AVX)
|
||||
[Config(typeof(Config))]
|
||||
[AllJitsJob]
|
||||
public class Math_DoubleSqrt
|
||||
{
|
||||
private class Config : ManualConfig
|
||||
{
|
||||
public Config()
|
||||
{
|
||||
Add(Job.AllJits);
|
||||
}
|
||||
}
|
||||
private int counter;
|
||||
|
||||
[Benchmark]
|
||||
|
|
|
@ -1,22 +1,13 @@
|
|||
using System;
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using BenchmarkDotNet.Configs;
|
||||
using BenchmarkDotNet.Jobs;
|
||||
using BenchmarkDotNet.Attributes.Jobs;
|
||||
|
||||
namespace BenchmarkDotNet.Samples.Other
|
||||
{
|
||||
// You need RyuJit and AVX support for this benchmark
|
||||
[Config(typeof(Config))]
|
||||
[RyuJitX64Job]
|
||||
public class Math_DoubleSqrtAvx
|
||||
{
|
||||
private class Config : ManualConfig
|
||||
{
|
||||
public Config()
|
||||
{
|
||||
Add(Job.RyuJitX64);
|
||||
}
|
||||
}
|
||||
|
||||
// vxorpd xmm0,xmm0,xmm0
|
||||
// vsqrtsd xmm0,xmm0,xmm0
|
||||
// vsqrtsd xmm1,xmm0,mmword ptr [7FFF83C14D88h]
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
using System.Collections;
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
using System.Resources;
|
||||
using System.Reflection;
|
||||
using BenchmarkDotNet.Running;
|
||||
using BenchmarkDotNet.Portability;
|
||||
|
||||
namespace BenchmarkDotNet.Samples
|
||||
{
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
using BenchmarkDotNet.Columns;
|
||||
|
||||
namespace BenchmarkDotNet.Attributes.Columns
|
||||
{
|
||||
public class AllStatisticsColumnAttribute : ColumnConfigBaseAttribute
|
||||
{
|
||||
public AllStatisticsColumnAttribute() : base(StatisticColumn.AllStatistics)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,13 +3,13 @@ using BenchmarkDotNet.Columns;
|
|||
using BenchmarkDotNet.Configs;
|
||||
|
||||
namespace BenchmarkDotNet.Attributes.Columns
|
||||
{
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Assembly)]
|
||||
public abstract class ColumnConfigAttribute : Attribute, IConfigSource
|
||||
public abstract class ColumnConfigBaseAttribute : Attribute, IConfigSource
|
||||
{
|
||||
protected ColumnConfigAttribute(IColumn column)
|
||||
protected ColumnConfigBaseAttribute(params IColumn[] columns)
|
||||
{
|
||||
Config = ManualConfig.CreateEmpty().With(column);
|
||||
Config = ManualConfig.CreateEmpty().With(columns);
|
||||
}
|
||||
|
||||
public IConfig Config { get; }
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace BenchmarkDotNet.Attributes.Columns
|
||||
{
|
||||
public class KurtosisColumnAttribute : ColumnConfigAttribute
|
||||
public class KurtosisColumnAttribute : ColumnConfigBaseAttribute
|
||||
{
|
||||
public KurtosisColumnAttribute() : base(StatisticColumn.Kurtosis)
|
||||
{
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
using BenchmarkDotNet.Columns;
|
||||
|
||||
namespace BenchmarkDotNet.Attributes.Columns
|
||||
{
|
||||
public class MaxColumnAttribute : ColumnConfigBaseAttribute
|
||||
{
|
||||
public MaxColumnAttribute() : base(StatisticColumn.Max)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
using BenchmarkDotNet.Columns;
|
||||
|
||||
namespace BenchmarkDotNet.Attributes.Columns
|
||||
{
|
||||
public class MeanColumnAttribute : ColumnConfigBaseAttribute
|
||||
{
|
||||
public MeanColumnAttribute() : base(StatisticColumn.Mean)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
using BenchmarkDotNet.Columns;
|
||||
|
||||
namespace BenchmarkDotNet.Attributes.Columns
|
||||
{
|
||||
public class MedianColumnAttribute : ColumnConfigBaseAttribute
|
||||
{
|
||||
public MedianColumnAttribute() : base(StatisticColumn.Median)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
using BenchmarkDotNet.Columns;
|
||||
|
||||
namespace BenchmarkDotNet.Attributes.Columns
|
||||
{
|
||||
public class MinColumnAttribute : ColumnConfigBaseAttribute
|
||||
{
|
||||
public MinColumnAttribute() : base(StatisticColumn.Min)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
using BenchmarkDotNet.Columns;
|
||||
|
||||
namespace BenchmarkDotNet.Attributes.Columns
|
||||
{
|
||||
public class Q1ColumnAttribute : ColumnConfigBaseAttribute
|
||||
{
|
||||
public Q1ColumnAttribute() : base(StatisticColumn.Q1)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
using BenchmarkDotNet.Columns;
|
||||
|
||||
namespace BenchmarkDotNet.Attributes.Columns
|
||||
{
|
||||
public class Q3ColumnAttribute : ColumnConfigBaseAttribute
|
||||
{
|
||||
public Q3ColumnAttribute() : base(StatisticColumn.Q3)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace BenchmarkDotNet.Attributes.Columns
|
||||
{
|
||||
public class SkewnessColumnAttribute : ColumnConfigAttribute
|
||||
public class SkewnessColumnAttribute : ColumnConfigBaseAttribute
|
||||
{
|
||||
public SkewnessColumnAttribute() : base(StatisticColumn.Skewness)
|
||||
{
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
using BenchmarkDotNet.Columns;
|
||||
|
||||
namespace BenchmarkDotNet.Attributes.Columns
|
||||
{
|
||||
public class StdDevColumnAttribute : ColumnConfigBaseAttribute
|
||||
{
|
||||
public StdDevColumnAttribute() : base(StatisticColumn.StdDev)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
using BenchmarkDotNet.Columns;
|
||||
|
||||
namespace BenchmarkDotNet.Attributes.Columns
|
||||
{
|
||||
public class StdErrorColumnAttribute : ColumnConfigBaseAttribute
|
||||
{
|
||||
public StdErrorColumnAttribute() : base(StatisticColumn.StdError)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace BenchmarkDotNet.Attributes.Columns
|
||||
{
|
||||
public class WelchTTestPValueColumnAttribute : ColumnConfigAttribute
|
||||
public class WelchTTestPValueColumnAttribute : ColumnConfigBaseAttribute
|
||||
{
|
||||
public WelchTTestPValueColumnAttribute() : base(BaselineScaledColumn.WelchTTestPValue)
|
||||
{
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
using BenchmarkDotNet.Exporters;
|
||||
|
||||
namespace BenchmarkDotNet.Attributes.Exporters
|
||||
{
|
||||
public class AsciiDocExporterAttribute : ExporterConfigBaseAttribute
|
||||
{
|
||||
public AsciiDocExporterAttribute() : base(DefaultExporters.AsciiDoc)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
using BenchmarkDotNet.Exporters;
|
||||
|
||||
namespace BenchmarkDotNet.Attributes.Exporters
|
||||
{
|
||||
public class BriefJsonExporterAttribute : ExporterConfigBaseAttribute
|
||||
{
|
||||
public BriefJsonExporterAttribute() : base(DefaultExporters.BriefJson)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
using BenchmarkDotNet.Exporters;
|
||||
|
||||
namespace BenchmarkDotNet.Attributes.Exporters
|
||||
{
|
||||
public class CsvExporterAttribute : ExporterConfigBaseAttribute
|
||||
{
|
||||
public CsvExporterAttribute() : base(DefaultExporters.Csv)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
using BenchmarkDotNet.Exporters;
|
||||
|
||||
namespace BenchmarkDotNet.Attributes.Exporters
|
||||
{
|
||||
public class CsvMeasurementsExporterAttribute : ExporterConfigBaseAttribute
|
||||
{
|
||||
public CsvMeasurementsExporterAttribute() : base(DefaultExporters.CsvMeasurements)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
using System;
|
||||
using BenchmarkDotNet.Configs;
|
||||
using BenchmarkDotNet.Exporters;
|
||||
|
||||
namespace BenchmarkDotNet.Attributes.Exporters
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Assembly)]
|
||||
public class ExporterConfigBaseAttribute : Attribute, IConfigSource
|
||||
{
|
||||
protected ExporterConfigBaseAttribute(params IExporter[] exporters)
|
||||
{
|
||||
Config = ManualConfig.CreateEmpty().With(exporters);
|
||||
}
|
||||
|
||||
public IConfig Config { get; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
using BenchmarkDotNet.Exporters;
|
||||
|
||||
namespace BenchmarkDotNet.Attributes.Exporters
|
||||
{
|
||||
public class FormattedJsonExporterAttribute : ExporterConfigBaseAttribute
|
||||
{
|
||||
public FormattedJsonExporterAttribute() : base(DefaultExporters.FormattedJson)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
using BenchmarkDotNet.Exporters;
|
||||
|
||||
namespace BenchmarkDotNet.Attributes.Exporters
|
||||
{
|
||||
public class HtmlExporterAttribute : ExporterConfigBaseAttribute
|
||||
{
|
||||
public HtmlExporterAttribute() : base(DefaultExporters.Html)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
using BenchmarkDotNet.Exporters;
|
||||
|
||||
namespace BenchmarkDotNet.Attributes.Exporters
|
||||
{
|
||||
public class MarkdownExporterAttribute : ExporterConfigBaseAttribute
|
||||
{
|
||||
public MarkdownExporterAttribute() : base(DefaultExporters.Markdown)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
using BenchmarkDotNet.Exporters;
|
||||
|
||||
namespace BenchmarkDotNet.Attributes.Exporters
|
||||
{
|
||||
public class PlainExporterAttribute : ExporterConfigBaseAttribute
|
||||
{
|
||||
public PlainExporterAttribute() : base(DefaultExporters.Plain)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
using BenchmarkDotNet.Exporters;
|
||||
|
||||
namespace BenchmarkDotNet.Attributes.Exporters
|
||||
{
|
||||
public class RPlotExporterAttribute : ExporterConfigBaseAttribute
|
||||
{
|
||||
public RPlotExporterAttribute() : base(DefaultExporters.RPlot)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
using BenchmarkDotNet.Jobs;
|
||||
|
||||
namespace BenchmarkDotNet.Attributes.Jobs
|
||||
{
|
||||
public class AllJitsJobAttribute : JobConfigBaseAttribute
|
||||
{
|
||||
public AllJitsJobAttribute() : base(Job.AllJits)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
using BenchmarkDotNet.Jobs;
|
||||
|
||||
namespace BenchmarkDotNet.Attributes.Jobs
|
||||
{
|
||||
public class ClrJobAttribute : JobConfigBaseAttribute
|
||||
{
|
||||
public ClrJobAttribute() : base(Job.Clr)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
using BenchmarkDotNet.Jobs;
|
||||
|
||||
namespace BenchmarkDotNet.Attributes.Jobs
|
||||
{
|
||||
public class CoreJobAttribute : JobConfigBaseAttribute
|
||||
{
|
||||
public CoreJobAttribute() : base(Job.Core)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
using BenchmarkDotNet.Jobs;
|
||||
|
||||
namespace BenchmarkDotNet.Attributes.Jobs
|
||||
{
|
||||
public class DryJobAttribute : JobConfigBaseAttribute
|
||||
{
|
||||
public DryJobAttribute() : base(Job.Dry)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,11 +5,11 @@ using BenchmarkDotNet.Jobs;
|
|||
namespace BenchmarkDotNet.Attributes.Jobs
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Assembly)]
|
||||
public class JobProviderAttribute : Attribute, IConfigSource
|
||||
public class JobConfigBaseAttribute : Attribute, IConfigSource
|
||||
{
|
||||
protected JobProviderAttribute(IJob job)
|
||||
protected JobConfigBaseAttribute(params IJob[] jobs)
|
||||
{
|
||||
Config = ManualConfig.CreateEmpty().With(job);
|
||||
Config = ManualConfig.CreateEmpty().With(jobs);
|
||||
}
|
||||
|
||||
public IConfig Config { get; }
|
|
@ -0,0 +1,11 @@
|
|||
using BenchmarkDotNet.Jobs;
|
||||
|
||||
namespace BenchmarkDotNet.Attributes.Jobs
|
||||
{
|
||||
public class LegacyJitX64JobAttribute : JobConfigBaseAttribute
|
||||
{
|
||||
public LegacyJitX64JobAttribute() : base(Job.LegacyJitX64)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
using BenchmarkDotNet.Jobs;
|
||||
|
||||
namespace BenchmarkDotNet.Attributes.Jobs
|
||||
{
|
||||
public class LegacyJitX86JobAttribute : JobConfigBaseAttribute
|
||||
{
|
||||
public LegacyJitX86JobAttribute() : base(Job.LegacyJitX86)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace BenchmarkDotNet.Attributes.Jobs
|
||||
{
|
||||
public class LongRunJobAttribute : JobProviderAttribute
|
||||
public class LongRunJobAttribute : JobConfigBaseAttribute
|
||||
{
|
||||
public LongRunJobAttribute() : base(Job.LongRun)
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace BenchmarkDotNet.Attributes.Jobs
|
||||
{
|
||||
public class MediumRunJobAttribute : JobProviderAttribute
|
||||
public class MediumRunJobAttribute : JobConfigBaseAttribute
|
||||
{
|
||||
public MediumRunJobAttribute() : base(Job.MediumRun)
|
||||
{
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
using BenchmarkDotNet.Jobs;
|
||||
|
||||
namespace BenchmarkDotNet.Attributes.Jobs
|
||||
{
|
||||
public class MonoJobAttribute : JobConfigBaseAttribute
|
||||
{
|
||||
public MonoJobAttribute() : base(Job.Mono)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
using BenchmarkDotNet.Jobs;
|
||||
|
||||
namespace BenchmarkDotNet.Attributes.Jobs
|
||||
{
|
||||
public class RyuJitX64JobAttribute : JobConfigBaseAttribute
|
||||
{
|
||||
public RyuJitX64JobAttribute() : base(Job.RyuJitX64)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
using BenchmarkDotNet.Exporters.Json;
|
||||
|
||||
namespace BenchmarkDotNet.Exporters
|
||||
{
|
||||
public static class DefaultExporters
|
||||
{
|
||||
public static IExporter AsciiDoc = AsciiDocExporter.Default;
|
||||
public static IExporter Csv = CsvExporter.Default;
|
||||
public static IExporter CsvMeasurements = CsvMeasurementsExporter.Default;
|
||||
public static IExporter Html = HtmlExporter.Default;
|
||||
public static IExporter Markdown = MarkdownExporter.Default;
|
||||
public static IExporter Plain = PlainExporter.Default;
|
||||
public static IExporter RPlot = RPlotExporter.Default;
|
||||
public static IExporter BriefJson = BriefJsonExporter.Default;
|
||||
public static IExporter FormattedJson = FormattedJsonExporter.Default;
|
||||
}
|
||||
|
||||
|
||||
}
|
19
README.md
19
README.md
|
@ -153,7 +153,22 @@ public class MyClassWithBenchmarks
|
|||
}
|
||||
```
|
||||
|
||||
* **Custom configs**
|
||||
* **Attribute style**
|
||||
|
||||
You can also use a set of predefined config attributes:
|
||||
|
||||
```cs
|
||||
[ClrJob, MonoJob, CoreJob]
|
||||
[SkewnessColumn, KurtosisColumn, WelchTTestPValueColumn]
|
||||
[RPlotExporter, AsciiDocExporter, HtmlExporter]
|
||||
public class MyClassWithBenchmarks
|
||||
{
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
* **Custom style**
|
||||
|
||||
You can also define own config attribute:
|
||||
|
||||
|
@ -180,7 +195,7 @@ public class IntroConfigSource
|
|||
}
|
||||
```
|
||||
|
||||
* **Fluent config**
|
||||
* **Fluent style**
|
||||
|
||||
There is no need to create new Config type, you can simply use fluent interface:
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче