AyCode.Core/AyCode.Benchmark/Workloads/Scenarios
Loretta cf92370bea Refactor AcBinarySerializer to use declared type dispatch
- All serialization APIs now use the declared type (typeof(T) or explicit Type) for dispatch, not value.GetType()
- Added non-generic overloads for Serialize, SerializeChunked, and SerializeChunkedFramed with Type parameter for runtime scenarios
- ScanForDuplicates accepts optional TypeMetadataWrapper to avoid redundant lookups
- Simplified generated writer path and improved wrapper usage
- Benchmarks updated to use new API and cache serialized data
- Minor cleanups: removed unused usings, improved comments, inlined logic
- Ensures consistent, predictable, and more performant type dispatch across all serialization entry points
2026-05-26 07:56:25 +02:00
..
AcBinaryBenchmark.cs Refactor AcBinarySerializer to use declared type dispatch 2026-05-26 07:56:25 +02:00
AcBinaryBufferWriterBenchmark.cs Refactor AcBinarySerializer to use declared type dispatch 2026-05-26 07:56:25 +02:00
AcBinaryFreshBufferWriterBenchmark.cs Refactor: move benchmark engines to shared scenarios 2026-05-15 19:55:52 +02:00
AcBinaryInMemoryPipeBenchmark.cs Refactor: move benchmark engines to shared scenarios 2026-05-15 19:55:52 +02:00
AcBinaryInMemoryRawByteArrayBenchmark.cs Refactor: move benchmark engines to shared scenarios 2026-05-15 19:55:52 +02:00
AcBinaryNamedPipeBenchmark.cs Refactor: move benchmark engines to shared scenarios 2026-05-15 19:55:52 +02:00
AcBinaryNamedPipeRawByteArrayBenchmark.cs Refactor: move benchmark engines to shared scenarios 2026-05-15 19:55:52 +02:00
BenchmarkEnums.cs Refactor: move benchmark engines to shared scenarios 2026-05-15 19:55:52 +02:00
BenchmarkOptions.cs Refactor: move benchmark engines to shared scenarios 2026-05-15 19:55:52 +02:00
ISerializerBenchmark.cs Refactor: move benchmark engines to shared scenarios 2026-05-15 19:55:52 +02:00
MemoryPackBenchmark.cs Refactor: move benchmark engines to shared scenarios 2026-05-15 19:55:52 +02:00
MemoryPackBufferWriterBenchmark.cs Refactor: move benchmark engines to shared scenarios 2026-05-15 19:55:52 +02:00
MemoryPackFreshBufferWriterBenchmark.cs Refactor: move benchmark engines to shared scenarios 2026-05-15 19:55:52 +02:00
MessagePackBenchmark.cs Refactor: move benchmark engines to shared scenarios 2026-05-15 19:55:52 +02:00
README.md Refactor: BDN runner, unified reporting, doc overhaul 2026-05-15 20:54:42 +02:00
RoundTripValidator.cs Refactor: move benchmark engines to shared scenarios 2026-05-15 19:55:52 +02:00
SystemTextJsonBenchmark.cs Refactor: move benchmark engines to shared scenarios 2026-05-15 19:55:52 +02:00

README.md

Workloads / Scenarios

Shared workload + scenario types used by both the Console runner (custom adaptive measure engine) and the BDN runner (AcBinaryVsMemPackBenchmark in the parent folder). Same wire payloads, same options, same round-trip-verify gate → Console and BDN cells are directly comparable.

Layout

Contract types

  • ISerializerBenchmark.cs — common contract for every (Engine × IoMode × OptionsPreset) row. Serialize() / Deserialize() hot-path + warmup hooks + VerifyRoundTrip() for the pre-warmup correctness gate. Round-trip-only benchmarks (NamedPipe / in-memory Pipe) set IsRoundTripOnly = true and let the bench loop skip the Des-phase.
  • BenchmarkEnums.csBenchmarkEngine / BenchmarkIoMode / BenchmarkDispatchMode / BenchmarkLayer / BenchmarkOpMode / SerializerSelectionMode + ToDisplay() extensions for the column-friendly rendering used by every output formatter.
  • BenchmarkOptions.cs — per-engine options-formatting helpers + the cached AttrFlags aggregation (assembly-scan of [AcBinarySerializable] feature flags) + GetMemPack(WireMode) for the wire-mode-aligned MemoryPack-options selection.
  • RoundTripValidator.cs — universal deep-equality oracle via canonical System.Text.Json. Called by every benchmark's VerifyRoundTrip() before warmup. AOT-skipped (STJ reflection path incompatible).

Concrete benchmarks (12 implementations)

AcBinary (7 variants — different I/O modes):

MemoryPack (3 variants — apples-to-apples with the AcBinary I/O modes):

Other (reference comparison, typically disabled in active suite):

  • MessagePackBenchmark.cs — JIT-only (AOT-incompatible — v3 StandardResolver falls back to Activator.CreateInstance on trimmed closed-generic types).
  • SystemTextJsonBenchmark.cs — String I/O mode, reflection-based metadata. Far behind binary serializers on µs/op; useful as a JSON baseline when activated.

Convention

Every concrete benchmark:

  1. Stores the test data graph + serializer options in its ctor and pre-computes a _serialized byte array for SerializedSize reporting.
  2. Implements Serialize() / Deserialize() as [MethodImpl(NoInlining)] hot-paths — the bench loop drives these directly through warmup + adaptive-iter calibration + measurement.
  3. Implements VerifyRoundTrip() by calling RoundTripValidator.DeepEqualsViaJson(original, roundTripped) on the result of a single Ser+Des pass.
  4. Round-trip-only variants (NamedPipe / in-memory Pipe) override IsRoundTripOnly => true, route the full Ser+wire+Des roundtrip through Serialize(), and leave Deserialize() as a no-op.

The runner (Console BenchmarkLoop or BDN AcBinaryVsMemPackBenchmark) creates the appropriate concrete via factory helpers and drives the contract — no scenario-specific knowledge in the runner.