diff --git a/Benchmarks/Open.Database.Extensions.Benchmarks.Generated/SingleValueReads.cs b/Benchmarks/Open.Database.Extensions.Benchmarks.Generated/SingleValueReads.cs
new file mode 100644
index 00000000..6313fb43
--- /dev/null
+++ b/Benchmarks/Open.Database.Extensions.Benchmarks.Generated/SingleValueReads.cs
@@ -0,0 +1,19 @@
+using Open.Database.Extensions.Synchronous;
+
+namespace Open.Database.Extensions.Benchmarks.Generated;
+
+/// The ODX rungs of the single-value gate table: column 0 of every row.
+public static class SingleValueReads
+{
+ /// The hand-written selector.
+ public static List Hand(IExecuteReader command)
+ => command.Map(static r => r.GetInt32(0)).ToList();
+
+ /// The A/A control: the same selector, compiled as a method of its own.
+ public static List HandCopy(IExecuteReader command)
+ => command.Map(static r => r.GetInt32(0)).ToList();
+
+ /// Map<int>() as shipped: the generator declines a single value, so the runtime map reads it.
+ public static List Shipped(IExecuteReader command)
+ => command.Map().ToList();
+}
diff --git a/Benchmarks/Open.Database.Extensions.Benchmarks/GateBenchmarks.cs b/Benchmarks/Open.Database.Extensions.Benchmarks/GateBenchmarks.cs
index b306f466..48e58302 100644
--- a/Benchmarks/Open.Database.Extensions.Benchmarks/GateBenchmarks.cs
+++ b/Benchmarks/Open.Database.Extensions.Benchmarks/GateBenchmarks.cs
@@ -27,6 +27,9 @@ namespace Open.Database.Extensions.Benchmarks;
// Gen_T the generated reader of the unannotated model
// Selector the selector a caller writes, Map(selector)
// Dapper.AOT and Dapper: in both tables; unforced in the sequential one (their own mode), forced in the default one and labelled so.
+// RawAdo_T reference, not gated: plain ADO.NET with no library (RawAdoReads). What it takes less than CtlH_T is the library's own cost.
+//
+// GateSingleValueBenchmarks is the third table, default access: column 0 of every row (Map of one value), over the same sources and row counts.
//
// Every rung, forced or not, reads through ReadModeConnection (benchmarks only; library defaults are unchanged), so no rung pays a layer
// another does not, and setup checks the mode its rung read in. No gate table holds a cross-mode ratio; what the mode itself costs is
@@ -58,15 +61,14 @@ public static int Verify()
{
foreach (int rows in GateShapes.RowValues)
{
- Run(new GateDefaultAccessBenchmarks());
- Run(new GateSequentialAccessBenchmarks());
- Run(new ReadModeEffectBenchmarks { Generated = false });
- Run(new ReadModeEffectBenchmarks { Generated = true });
+ Run(new GateDefaultAccessBenchmarks { Width = width });
+ Run(new GateSequentialAccessBenchmarks { Width = width });
+ Run(new ReadModeEffectBenchmarks { Width = width, Generated = false });
+ Run(new ReadModeEffectBenchmarks { Width = width, Generated = true });
void Run(GateShapes gate)
{
gate.Source = source;
- gate.Width = width;
gate.Rows = rows;
gate.VerifyAll();
gate.Cleanup();
@@ -74,6 +76,14 @@ void Run(GateShapes gate)
}
}
}
+
+ foreach (int rows in GateShapes.RowValues)
+ {
+ var single = new GateSingleValueBenchmarks { Source = source, Rows = rows };
+ single.VerifyAll();
+ single.Cleanup();
+ cases++;
+ }
}
Console.WriteLine($"// GATE-VERIFY {cases} cases: every rung read the right rows in its table's mode.");
@@ -130,22 +140,17 @@ .. benchmarksCase
}
}
-/// The case every gate table shares: where the rows come from, how wide and how many.
-public abstract class GateShapes
+/// What every gate table shares: where the rows come from and how many.
+public abstract class GateSource
{
public const string Synthetic = "Synthetic";
[ParamsSource(nameof(SourceValues), Priority = 0)]
public string Source { get; set; } = "";
- [ParamsSource(nameof(WidthValues), Priority = 1)]
- public int Width { get; set; }
-
[ParamsSource(nameof(RowValues), Priority = 2)]
public int Rows { get; set; }
- public static IEnumerable WidthValues => SyntheticParams.Parse(Environment.GetEnvironmentVariable("ODX_GATE_WIDTHS"), [10, 20]);
-
public static IEnumerable RowValues => SyntheticParams.Parse(Environment.GetEnvironmentVariable("ODX_GATE_ROWS"), [1, 1000, 10_000]);
public static IEnumerable SourceValues
@@ -155,38 +160,34 @@ public static IEnumerable SourceValues
RealProviderCase? _case;
DbConnection _connection = null!;
- List _expected = null!;
- protected void Open()
+ protected void Connect(int width)
{
if (Source == Synthetic)
{
- _connection = new SyntheticConnection(SyntheticTable.Create(Width, Rows), new SyntheticOptions());
+ _connection = new SyntheticConnection(SyntheticTable.Create(width, Rows), new SyntheticOptions());
RealProviderVariants.PrepareDapper(RealProviderParams.SqlServer); // No type handlers.
}
else
{
- _case = RealProviderCase.Create(Source, Width, Rows);
+ _case = RealProviderCase.Create(Source, width, Rows);
_connection = _case.Real;
RealProviderVariants.PrepareDapper(Source);
}
- // The oracle, read with plain ADO.NET: a process times one rung, and no other reading may go through the library's shared read loop first.
- _expected = Oracle();
- if (_expected.Count != Rows) throw new InvalidOperationException($"{_expected.Count} rows, expected {Rows}.");
-
// One line per process in the log: which case it ran.
- Console.WriteLine($"// GATE-PID {Environment.ProcessId} {System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription} {GetType().Name} {Source} width={Width} rows={Rows}");
+ Console.WriteLine($"// GATE-PID {Environment.ProcessId} {System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription} {GetType().Name} {Source} width={width} rows={Rows}");
}
- List Oracle()
+ // The oracle, read with plain ADO.NET: a process times one rung, and no other reading may go through the library's shared read loop first.
+ protected List Oracle(Func hand)
{
- Func hand = SyntheticVariants.Hand(Width);
using DbCommand command = _connection.CreateCommand();
command.CommandText = RealProviderVariants.Sql;
using DbDataReader reader = command.ExecuteReader();
- var rows = new List();
+ var rows = new List();
while (reader.Read()) rows.Add(hand(reader));
+ if (rows.Count != Rows) throw new InvalidOperationException($"{rows.Count} rows, expected {Rows}.");
return rows;
}
@@ -196,18 +197,41 @@ List Oracle()
/// The case's connection in the given read mode; leaves each reader as its caller asks.
protected ReadModeConnection In(bool? sequential) => new(_connection, sequential);
- // No case is timed over wrong rows or in another read mode than its table's; in a counters build a generated rung must be served by generated code.
- protected void Check(string rung, ReadModeConnection connection, bool sequential, Func