Path: redb/redb.Examples/Output/ExampleRunLog.cs Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Examples/Output/ExampleRunLog.cs ---- using System.Reflection; using Microsoft.EntityFrameworkCore; using redb.Core; using redb.Core.Models.Entities; using redb.Examples.Models; namespace redb.Examples.Output; /// /// The run history of the examples: every pass of every example in every run, stored in the results database as /// objects under the example's object. /// public static class ExampleRunLog { /// /// One per stored pass of . A skipped result is left out, /// as it is left out of . /// /// The passes of the run under their platform keys (postgres.pro, sqlite.pro.cache, postgres.ef.repeat...). /// Start of the run. /// Id of the run. /// The Pro planner setting of the run (EnablePvtPrefilter), recorded on redb Pro passes only. public static List Build( IEnumerable<(string Platform, ExampleResult Result)> runs, DateTimeOffset runAt, Guid runId, bool planner) { var redbVersion = VersionOf(typeof(IRedbService)); var efVersion = VersionOf(typeof(DbContext)); var rows = new List(); foreach (var (platform, result) in runs.Where(r => !r.Result.Skipped)) { // platform key: [.pro|.ef][.repeat|.cache] var parts = platform.Split('.'); var isEf = parts.Length > 1 && parts[1] == "ef"; var isPro = parts.Length > 1 && parts[1] == "pro"; var pass = parts.Length > 1 && parts[^1] is "repeat" or "cache" ? parts[^1] : "first"; rows.Add(new ExampleRunProps { ExampleId = result.Id.EndsWith("_ef", StringComparison.OrdinalIgnoreCase) ? result.Id[..^3] : result.Id, Engine = isEf ? "ef" : "redb", Edition = isEf ? null : isPro ? "Pro" : "Free", Provider = parts[0], Planner = isPro ? planner : null, Pass = pass, Platform = platform, TimeMs = result.NotSupported ? null : result.ElapsedMs, Count = result.Count, Queries = result.Queries, Status = result.NotSupported ? $"N/A: {result.Output.FirstOrDefault()}" : result.Success ? "OK" : (result.Error ?? "FAIL"), RunAt = runAt, RunId = runId, Version = isEf ? efVersion : redbVersion }); } return rows; } /// /// Saves the passes of the run in one batch, each under the result object of its example. The result objects /// must be saved already (they carry their ids). /// /// The results database. /// The example result objects by example id (E015). /// The passes of the run. /// Start of the run. /// Id of the run. /// The Pro planner setting of the run. public static async Task SaveAsync( IRedbService resultsDb, IReadOnlyDictionary> resultByKey, IEnumerable<(string Platform, ExampleResult Result)> runs, DateTimeOffset runAt, Guid runId, bool planner) { var rows = Build(runs, runAt, runId, planner); if (rows.Count == 0) return; await resultsDb.SyncSchemeAsync(); var objects = rows.Select(row => new RedbObject { Name = $"{row.ExampleId} {row.Platform}", ParentId = resultByKey[row.ExampleId].Id, ValueDatetime = row.RunAt, Props = row }).ToList(); await resultsDb.SaveAsync(objects); Console.WriteLine($"Run history saved: {objects.Count} pass(es), run {runId:N} at {runAt:u}"); } private static string VersionOf(Type type) => type.Assembly.GetCustomAttribute()?.InformationalVersion.Split('+')[0] ?? type.Assembly.GetName().Version?.ToString() ?? "?"; }