namespace AyCode.Core.Serializers.Console.Benchmarks; /// /// Serializer engine identifier — replaces the prior Configuration.EngineXxx string constants /// with a type-safe enum. The benchmark-result Engine column uses for /// the human-readable form. /// internal enum BenchmarkEngine { AcBinary, MemoryPack, #if !AYCODE_NATIVEAOT MessagePack, #endif SystemTextJson, } /// /// I/O mode identifier — replaces the prior Configuration.IoXxx string constants. Note that /// and share the display string "NamedPipe" /// (they distinguish chunked-framed vs raw-byte[] semantics, but render identically in the IO column); /// the same applies to + ("Pipe(in-mem)"). /// internal enum BenchmarkIoMode { ByteArray, BufWrReuse, BufWrNew, String, NamedPipe, NamedPipeRaw, InMemoryPipe, InMemoryRaw, } /// /// Dispatch mode identifier — replaces the prior Configuration.ModeXxx string constants. /// Describes how property access / type dispatch happens for a given benchmark row: /// /// — compile-time source generator path (Unsafe.As<T> direct fields, slot-array wrapper lookup). /// — reflection / compiled-delegate path. /// — SGen root with non-SGen child types reached via bridge methods (see docs/BINARY/BINARY_SGEN.md). /// /// internal enum BenchmarkDispatchMode { SGen, Runtime, Hybrid, } /// /// 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 .log file CSV/formatted output, /// and the .LLM markdown table. Centralised here so every output formatter renders identically. /// 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), }; }