Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -974,10 +974,12 @@ public static async Task AQueryFactory_LetsEachCallerPickTheTerminal()

static PlainReaderCommand Ints(int count)
{
DataTable table = new();
table.Columns.Add("v", typeof(int));
for (int i = 0; i < count; i++) table.Rows.Add(i);
return new PlainReaderCommand(() => new DataTableReader(table));
// A TypedReader serves cells boxed once, here, outside the measurement
// (a DataTableReader boxes each int again on every read,
// and the JIT removes that box part way through a measurement).
ImmutableArray<ColumnDef> columns = [("v", typeof(int))];
object?[][] rows = [.. Enumerable.Range(0, count).Select(i => (object?[])[i])];
return new PlainReaderCommand(() => TypedReader.Create(columns, rows));
}

// Bytes per call: after a warm-up,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,20 @@ static long BytesPerCall(Action call)
// the two differ by no more than a rounding of the measurement.
const int Slack = 16;

// A DataTableReader is a DbDataReader that reports its column type
// A TypedReader is a DbDataReader that reports its column type
// and has typed getters,
// so the typed (unboxed) path runs.
// Its cells are boxed once, here, outside the measurement
// (a DataTableReader boxes every int it serves,
// and the JIT removes that box part way through a measurement).
static PlainReaderCommand Rows(
Type column,
int count,
Func<int, object> value)
{
var table = new DataTable();
table.Columns.Add("v", column);
table.Columns.Add("other", typeof(string));
for (int i = 0; i < count; i++) table.Rows.Add(value(i), "x");
return new PlainReaderCommand(() => new DataTableReader(table));
ImmutableArray<ColumnDef> columns = [("v", column), ("other", typeof(string))];
object?[][] rows = [.. Enumerable.Range(0, count).Select(i => (object?[])[value(i), "x"])];
return new PlainReaderCommand(() => TypedReader.Create(columns, rows));
}

static void NoMoreThanByHand(
Expand Down
Loading