Move Smoke benchmarks to BenchmarkDotNet.Samples

IntroSmokeIncrements was taken from https://github.com/dotnet/BenchmarkDotNet/pull/2334#issuecomment-1988673372
This commit is contained in:
Andrey Akinshin 2024-08-28 09:56:35 +02:00
Родитель 92f33f21cb
Коммит 475ab4518c
5 изменённых файлов: 290 добавлений и 159 удалений

Просмотреть файл

@ -0,0 +1,82 @@
using BenchmarkDotNet.Attributes;
namespace BenchmarkDotNet.Samples;
[DisassemblyDiagnoser]
public class IntroSmokeEmptyBasic
{
[Benchmark] public void Void1() {}
[Benchmark] public void Void2() {}
[Benchmark] public void Void3() {}
[Benchmark] public void Void4() {}
[Benchmark] public byte Byte1() => 0;
[Benchmark] public byte Byte2() => 0;
[Benchmark] public byte Byte3() => 0;
[Benchmark] public byte Byte4() => 0;
[Benchmark] public sbyte Sbyte1() => 0;
[Benchmark] public sbyte Sbyte2() => 0;
[Benchmark] public sbyte Sbyte3() => 0;
[Benchmark] public sbyte Sbyte4() => 0;
[Benchmark] public short Short1() => 0;
[Benchmark] public short Short2() => 0;
[Benchmark] public short Short3() => 0;
[Benchmark] public short Short4() => 0;
[Benchmark] public ushort Ushort1() => 0;
[Benchmark] public ushort Ushort2() => 0;
[Benchmark] public ushort Ushort3() => 0;
[Benchmark] public ushort Ushort4() => 0;
[Benchmark] public int Int1() => 0;
[Benchmark] public int Int2() => 0;
[Benchmark] public int Int3() => 0;
[Benchmark] public int Int4() => 0;
[Benchmark] public uint Uint1() => 0u;
[Benchmark] public uint Uint2() => 0u;
[Benchmark] public uint Uint3() => 0u;
[Benchmark] public uint Uint4() => 0u;
[Benchmark] public bool Bool1() => false;
[Benchmark] public bool Bool2() => false;
[Benchmark] public bool Bool3() => false;
[Benchmark] public bool Bool4() => false;
[Benchmark] public char Char1() => 'a';
[Benchmark] public char Char2() => 'a';
[Benchmark] public char Char3() => 'a';
[Benchmark] public char Char4() => 'a';
[Benchmark] public float Float1() => 0f;
[Benchmark] public float Float2() => 0f;
[Benchmark] public float Float3() => 0f;
[Benchmark] public float Float4() => 0f;
[Benchmark] public double Double1() => 0d;
[Benchmark] public double Double2() => 0d;
[Benchmark] public double Double3() => 0d;
[Benchmark] public double Double4() => 0d;
[Benchmark] public long Long1() => 0L;
[Benchmark] public long Long2() => 0L;
[Benchmark] public long Long3() => 0L;
[Benchmark] public long Long4() => 0L;
[Benchmark] public ulong Ulong1() => 0uL;
[Benchmark] public ulong Ulong2() => 0uL;
[Benchmark] public ulong Ulong3() => 0uL;
[Benchmark] public ulong Ulong4() => 0uL;
[Benchmark] public string String1() => "";
[Benchmark] public string String2() => "";
[Benchmark] public string String3() => "";
[Benchmark] public string String4() => "";
[Benchmark] public object? Object1() => null;
[Benchmark] public object? Object2() => null;
[Benchmark] public object? Object3() => null;
[Benchmark] public object? Object4() => null;
}

Просмотреть файл

@ -0,0 +1,138 @@
using BenchmarkDotNet.Attributes;
namespace BenchmarkDotNet.Samples;
public class IntroSmokeIncrements
{
public int Field;
[Benchmark]
public void Increment01()
{
Field++;
}
[Benchmark]
public void Increment02()
{
Field++;
Field++;
}
[Benchmark]
public void Increment03()
{
Field++;
Field++;
Field++;
}
[Benchmark]
public void Increment04()
{
Field++;
Field++;
Field++;
Field++;
}
[Benchmark]
public void Increment05()
{
Field++;
Field++;
Field++;
Field++;
Field++;
}
[Benchmark]
public void Increment06()
{
Field++;
Field++;
Field++;
Field++;
Field++;
Field++;
}
[Benchmark]
public void Increment07()
{
Field++;
Field++;
Field++;
Field++;
Field++;
Field++;
Field++;
}
[Benchmark]
public void Increment08()
{
Field++;
Field++;
Field++;
Field++;
Field++;
Field++;
Field++;
Field++;
}
[Benchmark]
public void Increment09()
{
Field++;
Field++;
Field++;
Field++;
Field++;
Field++;
Field++;
Field++;
Field++;
}
[Benchmark]
public void Increment10()
{
Field++;
Field++;
Field++;
Field++;
Field++;
Field++;
Field++;
Field++;
Field++;
Field++;
}
[Benchmark]
public void Increment20()
{
Field++;
Field++;
Field++;
Field++;
Field++;
Field++;
Field++;
Field++;
Field++;
Field++;
Field++;
Field++;
Field++;
Field++;
Field++;
Field++;
Field++;
Field++;
Field++;
Field++;
}
}

Просмотреть файл

@ -0,0 +1,70 @@
using System;
using System.Threading.Tasks;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Environments;
namespace BenchmarkDotNet.Samples;
[MemoryDiagnoser, DisassemblyDiagnoser]
public class IntroSmokeValueTypes
{
[Benchmark] public Jit ReturnEnum() => Jit.RyuJit;
[Benchmark] public DateTime ReturnDateTime() => new DateTime();
[Benchmark] public DateTime? ReturnNullableDateTime() => new DateTime();
[Benchmark] public int? ReturnNullableInt() => 0;
public struct StructWithReferencesOnly { public object _ref; }
[Benchmark] public StructWithReferencesOnly ReturnStructWithReferencesOnly() => new StructWithReferencesOnly();
public struct EmptyStruct { }
[Benchmark] public EmptyStruct ReturnEmptyStruct() => new EmptyStruct();
[Benchmark] public ValueTuple<int> ReturnGenericStructOfValueType() => new ValueTuple<int>(0);
[Benchmark] public ValueTuple<object> ReturnGenericStructOfReferenceType() => new ValueTuple<object>(null);
[Benchmark] public ValueTask<int> ReturnValueTaskOfValueType() => new ValueTask<int>(0);
[Benchmark] public ValueTask<object> ReturnValueTaskOfReferenceType() => new ValueTask<object>(result: null);
[Benchmark] public byte ReturnByte() => 0;
public struct Byte1 { public byte _1; }
[Benchmark] public Byte1 ReturnByte1() => new Byte1();
public struct Byte2 { public byte _1, _2; }
[Benchmark] public Byte2 ReturnByte2() => new Byte2();
public struct Byte3 { public byte _1, _2, _3; }
[Benchmark] public Byte3 ReturnByte3() => new Byte3();
public struct Byte4 { public byte _1, _2, _3, _4; }
[Benchmark] public Byte4 ReturnByte4() => new Byte4();
[Benchmark] public short ReturnShort() => 0;
public struct Short1 { public short _1; }
[Benchmark] public Short1 ReturnShort1() => new Short1();
public struct Short2 { public short _1, _2; }
[Benchmark] public Short2 ReturnShort2() => new Short2();
public struct Short3 { public short _1, _2, _3; }
[Benchmark] public Short3 ReturnShort3() => new Short3();
public struct Short4 { public short _1, _2, _3, _4; }
[Benchmark] public Short4 ReturnShort4() => new Short4();
[Benchmark] public int ReturnInt() => 0;
public struct Int1 { public int _1; }
[Benchmark] public Int1 ReturnInt1() => new Int1();
public struct Int2 { public int _1, _2; }
[Benchmark] public Int2 ReturnInt2() => new Int2();
public struct Int3 { public int _1, _2, _3; }
[Benchmark] public Int3 ReturnInt3() => new Int3();
public struct Int4 { public int _1, _2, _3, _4; }
[Benchmark] public Int4 ReturnInt4() => new Int4();
[Benchmark] public long ReturnLong() => 0;
public struct Long1 { public long _1; }
[Benchmark] public Long1 ReturnLong1() => new Long1();
public struct Long2 { public long _1, _2; }
[Benchmark] public Long2 ReturnLong2() => new Long2();
public struct Long3 { public long _1, _2, _3; }
[Benchmark] public Long3 ReturnLong3() => new Long3();
public struct Long4 { public long _1, _2, _3, _4; }
[Benchmark] public Long4 ReturnLong4() => new Long4();
}
// ReSharper restore InconsistentNaming

Просмотреть файл

@ -1,85 +0,0 @@
using BenchmarkDotNet.Attributes;
namespace BenchmarkDotNet.IntegrationTests.ManualRunning.Smoke
{
[MedianColumn, Q3Column, MaxColumn]
[LegacyJitX64Job, RyuJitX64Job, MonoJob]
[KeepBenchmarkFiles]
public class SmokeEmpty
{
[Benchmark] public void Void1() {}
[Benchmark] public void Void2() {}
[Benchmark] public void Void3() {}
[Benchmark] public void Void4() {}
[Benchmark] public byte Byte1() => 0;
[Benchmark] public byte Byte2() => 0;
[Benchmark] public byte Byte3() => 0;
[Benchmark] public byte Byte4() => 0;
[Benchmark] public sbyte Sbyte1() => 0;
[Benchmark] public sbyte Sbyte2() => 0;
[Benchmark] public sbyte Sbyte3() => 0;
[Benchmark] public sbyte Sbyte4() => 0;
[Benchmark] public short Short1() => 0;
[Benchmark] public short Short2() => 0;
[Benchmark] public short Short3() => 0;
[Benchmark] public short Short4() => 0;
[Benchmark] public ushort Ushort1() => 0;
[Benchmark] public ushort Ushort2() => 0;
[Benchmark] public ushort Ushort3() => 0;
[Benchmark] public ushort Ushort4() => 0;
[Benchmark] public int Int1() => 0;
[Benchmark] public int Int2() => 0;
[Benchmark] public int Int3() => 0;
[Benchmark] public int Int4() => 0;
[Benchmark] public uint Uint1() => 0u;
[Benchmark] public uint Uint2() => 0u;
[Benchmark] public uint Uint3() => 0u;
[Benchmark] public uint Uint4() => 0u;
[Benchmark] public bool Bool1() => false;
[Benchmark] public bool Bool2() => false;
[Benchmark] public bool Bool3() => false;
[Benchmark] public bool Bool4() => false;
[Benchmark] public char Char1() => 'a';
[Benchmark] public char Char2() => 'a';
[Benchmark] public char Char3() => 'a';
[Benchmark] public char Char4() => 'a';
[Benchmark] public float Float1() => 0f;
[Benchmark] public float Float2() => 0f;
[Benchmark] public float Float3() => 0f;
[Benchmark] public float Float4() => 0f;
[Benchmark] public double Double1() => 0d;
[Benchmark] public double Double2() => 0d;
[Benchmark] public double Double3() => 0d;
[Benchmark] public double Double4() => 0d;
[Benchmark] public long Long1() => 0L;
[Benchmark] public long Long2() => 0L;
[Benchmark] public long Long3() => 0L;
[Benchmark] public long Long4() => 0L;
[Benchmark] public ulong Ulong1() => 0uL;
[Benchmark] public ulong Ulong2() => 0uL;
[Benchmark] public ulong Ulong3() => 0uL;
[Benchmark] public ulong Ulong4() => 0uL;
[Benchmark] public string String1() => "";
[Benchmark] public string String2() => "";
[Benchmark] public string String3() => "";
[Benchmark] public string String4() => "";
[Benchmark] public object Object1() => null;
[Benchmark] public object Object2() => null;
[Benchmark] public object Object3() => null;
[Benchmark] public object Object4() => null;
}
}

Просмотреть файл

@ -1,74 +0,0 @@
using System;
using System.Threading.Tasks;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Environments;
namespace BenchmarkDotNet.IntegrationTests.ManualRunning.Smoke
{
// ReSharper disable InconsistentNaming
[RyuJitX64Job, LegacyJitX64Job, LegacyJitX86Job]
[MemoryDiagnoser]
public class SmokeValueTypes
{
[Benchmark] public Jit ReturnEnum() => Jit.RyuJit;
[Benchmark] public DateTime ReturnDateTime() => new DateTime();
[Benchmark] public DateTime? ReturnNullableDateTime() => new DateTime();
[Benchmark] public int? ReturnNullableInt() => 0;
public struct StructWithReferencesOnly { public object _ref; }
[Benchmark] public StructWithReferencesOnly ReturnStructWithReferencesOnly() => new StructWithReferencesOnly();
public struct EmptyStruct { }
[Benchmark] public EmptyStruct ReturnEmptyStruct() => new EmptyStruct();
[Benchmark] public ValueTuple<int> ReturnGenericStructOfValueType() => new ValueTuple<int>(0);
[Benchmark] public ValueTuple<object> ReturnGenericStructOfReferenceType() => new ValueTuple<object>(null);
[Benchmark] public ValueTask<int> ReturnValueTaskOfValueType() => new ValueTask<int>(0);
[Benchmark] public ValueTask<object> ReturnValueTaskOfReferenceType() => new ValueTask<object>(result: null);
[Benchmark] public byte ReturnByte() => 0;
public struct Byte1 { public byte _1; }
[Benchmark] public Byte1 ReturnByte1() => new Byte1();
public struct Byte2 { public byte _1, _2; }
[Benchmark] public Byte2 ReturnByte2() => new Byte2();
public struct Byte3 { public byte _1, _2, _3; }
[Benchmark] public Byte3 ReturnByte3() => new Byte3();
public struct Byte4 { public byte _1, _2, _3, _4; }
[Benchmark] public Byte4 ReturnByte4() => new Byte4();
[Benchmark] public short ReturnShort() => 0;
public struct Short1 { public short _1; }
[Benchmark] public Short1 ReturnShort1() => new Short1();
public struct Short2 { public short _1, _2; }
[Benchmark] public Short2 ReturnShort2() => new Short2();
public struct Short3 { public short _1, _2, _3; }
[Benchmark] public Short3 ReturnShort3() => new Short3();
public struct Short4 { public short _1, _2, _3, _4; }
[Benchmark] public Short4 ReturnShort4() => new Short4();
[Benchmark] public int ReturnInt() => 0;
public struct Int1 { public int _1; }
[Benchmark] public Int1 ReturnInt1() => new Int1();
public struct Int2 { public int _1, _2; }
[Benchmark] public Int2 ReturnInt2() => new Int2();
public struct Int3 { public int _1, _2, _3; }
[Benchmark] public Int3 ReturnInt3() => new Int3();
public struct Int4 { public int _1, _2, _3, _4; }
[Benchmark] public Int4 ReturnInt4() => new Int4();
[Benchmark] public long ReturnLong() => 0;
public struct Long1 { public long _1; }
[Benchmark] public Long1 ReturnLong1() => new Long1();
public struct Long2 { public long _1, _2; }
[Benchmark] public Long2 ReturnLong2() => new Long2();
public struct Long3 { public long _1, _2, _3; }
[Benchmark] public Long3 ReturnLong3() => new Long3();
public struct Long4 { public long _1, _2, _3, _4; }
[Benchmark] public Long4 ReturnLong4() => new Long4();
}
// ReSharper restore InconsistentNaming
}