91 lines
3.4 KiB
C#
91 lines
3.4 KiB
C#
namespace AyCode.Core.Serializers.Console.Benchmarks;
|
|
|
|
/// <summary>
|
|
/// Serializer engine identifier — replaces the prior <c>Configuration.EngineXxx</c> string constants
|
|
/// with a type-safe enum. The benchmark-result <c>Engine</c> column uses <see cref="ToDisplay"/> for
|
|
/// the human-readable form.
|
|
/// </summary>
|
|
internal enum BenchmarkEngine
|
|
{
|
|
AcBinary,
|
|
MemoryPack,
|
|
#if !AYCODE_NATIVEAOT
|
|
MessagePack,
|
|
#endif
|
|
SystemTextJson,
|
|
}
|
|
|
|
/// <summary>
|
|
/// I/O mode identifier — replaces the prior <c>Configuration.IoXxx</c> string constants. Note that
|
|
/// <see cref="NamedPipe"/> and <see cref="NamedPipeRaw"/> share the display string <c>"NamedPipe"</c>
|
|
/// (they distinguish chunked-framed vs raw-byte[] semantics, but render identically in the IO column);
|
|
/// the same applies to <see cref="InMemoryPipe"/> + <see cref="InMemoryRaw"/> (<c>"Pipe(in-mem)"</c>).
|
|
/// </summary>
|
|
internal enum BenchmarkIoMode
|
|
{
|
|
ByteArray,
|
|
BufWrReuse,
|
|
BufWrNew,
|
|
String,
|
|
NamedPipe,
|
|
NamedPipeRaw,
|
|
InMemoryPipe,
|
|
InMemoryRaw,
|
|
}
|
|
|
|
/// <summary>
|
|
/// Dispatch mode identifier — replaces the prior <c>Configuration.ModeXxx</c> string constants.
|
|
/// Describes how property access / type dispatch happens for a given benchmark row:
|
|
/// <list type="bullet">
|
|
/// <item><see cref="SGen"/> — compile-time source generator path (Unsafe.As<T> direct fields, slot-array wrapper lookup).</item>
|
|
/// <item><see cref="Runtime"/> — reflection / compiled-delegate path.</item>
|
|
/// <item><see cref="Hybrid"/> — SGen root with non-SGen child types reached via bridge methods (see docs/BINARY/BINARY_SGEN.md).</item>
|
|
/// </list>
|
|
/// </summary>
|
|
internal enum BenchmarkDispatchMode
|
|
{
|
|
SGen,
|
|
Runtime,
|
|
Hybrid,
|
|
}
|
|
|
|
/// <summary>
|
|
/// Display-string converters for the benchmark enums. Renders enum values into the column-friendly
|
|
/// human-readable form used by the per-row console table, the <c>.log</c> file CSV/formatted output,
|
|
/// and the <c>.LLM</c> markdown table. Centralised here so every output formatter renders identically.
|
|
/// </summary>
|
|
internal static class BenchmarkEnumExtensions
|
|
{
|
|
internal static string ToDisplay(this BenchmarkEngine engine) => engine switch
|
|
{
|
|
BenchmarkEngine.AcBinary => "AcBinary",
|
|
BenchmarkEngine.MemoryPack => "MemoryPack",
|
|
#if !AYCODE_NATIVEAOT
|
|
BenchmarkEngine.MessagePack => "MessagePack",
|
|
#endif
|
|
BenchmarkEngine.SystemTextJson => "System.Text.Json",
|
|
_ => throw new ArgumentOutOfRangeException(nameof(engine), engine, null),
|
|
};
|
|
|
|
internal static string ToDisplay(this BenchmarkIoMode mode) => mode switch
|
|
{
|
|
BenchmarkIoMode.ByteArray => "Byte[]",
|
|
BenchmarkIoMode.BufWrReuse => "BufWr reuse",
|
|
BenchmarkIoMode.BufWrNew => "BufWr new",
|
|
BenchmarkIoMode.String => "String",
|
|
BenchmarkIoMode.NamedPipe => "NamedPipe",
|
|
BenchmarkIoMode.NamedPipeRaw => "NamedPipe",
|
|
BenchmarkIoMode.InMemoryPipe => "Pipe(in-mem)",
|
|
BenchmarkIoMode.InMemoryRaw => "Pipe(in-mem)",
|
|
_ => throw new ArgumentOutOfRangeException(nameof(mode), mode, null),
|
|
};
|
|
|
|
internal static string ToDisplay(this BenchmarkDispatchMode mode) => mode switch
|
|
{
|
|
BenchmarkDispatchMode.SGen => "SGen",
|
|
BenchmarkDispatchMode.Runtime => "Runtime",
|
|
BenchmarkDispatchMode.Hybrid => "Hybrid",
|
|
_ => throw new ArgumentOutOfRangeException(nameof(mode), mode, null),
|
|
};
|
|
}
|