Skip to content

Commit 1b757d0

Browse files
committed
Small improvements to benchmarking and logging
1 parent ec9231c commit 1b757d0

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

src/SeqCli/Cli/Commands/Bench/BenchCommand.cs

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,14 @@ protected override async Task<int> Run()
125125
var cancellationToken = cancellationTokenSource.Token;
126126

127127
using (LogContext.PushProperty("RunId", runId))
128+
using (LogContext.PushProperty("SeqVersion", seqVersion))
128129
using (LogContext.PushProperty("WithIngestion", _withIngestion))
129130
using (LogContext.PushProperty("WithQueries", _withQueries))
130131
using (LogContext.PushProperty("Start", _range.Start))
131132
using (LogContext.PushProperty("End", _range.End))
133+
using (!string.IsNullOrWhiteSpace(_description)
134+
? LogContext.PushProperty("Description", _description)
135+
: null)
132136
{
133137
if (_withIngestion)
134138
{
@@ -158,15 +162,19 @@ protected override async Task<int> Run()
158162
throw new Exception("Failed to query ingestion benchmark results");
159163
}
160164

161-
var counts = response.Slices.Select(s => Convert.ToDouble(s.Rows[0][0])).Where(c => c > 1000).ToArray();
165+
var counts = response.Slices.Skip(30) // ignore the warmup
166+
.Select(s => Convert.ToDouble(s.Rows[0][0])) // extract per-second counts
167+
.Where(c => c > 10000) // ignore any very small values
168+
.ToArray();
169+
counts = counts.SkipLast(5).ToArray(); // ignore warmdown
162170
var countsMean = counts.Sum() / counts.Length;
163171
var countsRSD = QueryBenchCaseTimings.StandardDeviation(counts) / countsMean;
164172

165-
using (LogContext.PushProperty("RunId", runId))
166173
using (LogContext.PushProperty("EventsPerSecond", counts))
167174
{
168175
reportingLogger.Information(
169-
"Ingestion benchmark {Description} ran for {RunDuration:N0}ms; ingested {TotalIngested:N0} at {EventsPerMinute:N0}events/min; with RSD {RelativeStandardDeviationPercentage,4:N1}%",
176+
"Ingestion benchmark {Description} ran for {RunDuration:N0}ms; ingested {TotalIngested:N0} "
177+
+ "at {EventsPerMinute:N0}events/min; with RSD {RelativeStandardDeviationPercentage,4:N1}%",
170178
_description,
171179
benchDurationMs,
172180
counts.Sum(),
@@ -196,14 +204,9 @@ protected override async Task<int> Run()
196204
async Task IngestionBenchmark(Logger reportingLogger, string runId, SeqConnection connection, string? apiKey,
197205
string seqVersion, bool isQueryBench, CancellationToken cancellationToken = default)
198206
{
199-
using (!string.IsNullOrWhiteSpace(_description)
200-
? LogContext.PushProperty("Description", _description)
201-
: null)
202-
{
203-
reportingLogger.Information(
204-
"Ingestion bench run {RunId} against {ServerUrl} ({SeqVersion})",
205-
runId, connection.Client.ServerUrl, seqVersion);
206-
}
207+
reportingLogger.Information(
208+
"Ingestion bench run {RunId} against {ServerUrl} ({SeqVersion})",
209+
runId, connection.Client.ServerUrl, seqVersion);
207210

208211
if (isQueryBench)
209212
{
@@ -224,14 +227,10 @@ async Task<CollectedTimings> QueryBenchmark(Logger reportingLogger, string runId
224227
{
225228
var cases = ReadCases(_cases);
226229
CollectedTimings collectedTimings = new(reportingLogger);
227-
using (!string.IsNullOrWhiteSpace(_description)
228-
? LogContext.PushProperty("Description", _description)
229-
: null)
230-
{
231-
reportingLogger.Information(
232-
"Query bench run {RunId} against {ServerUrl} ({SeqVersion}); {CaseCount} cases, {Runs} runs, from {Start} to {End}",
233-
runId, connection.Client.ServerUrl, seqVersion, cases.Cases.Count, _runs, _range.Start, _range.End);
234-
}
230+
reportingLogger.Information(
231+
"Query benchmark run {RunId} against {ServerUrl} ({SeqVersion}); {CaseCount} cases, {Runs} runs, from {Start} to {End}",
232+
runId, connection.Client.ServerUrl, seqVersion, cases.Cases.Count, _runs, _range.Start, _range.End);
233+
235234

236235
foreach (var c in cases.Cases.OrderBy(c => c.Id)
237236
.Concat(new [] { CollectedTimings.FINAL_COUNT_CASE }))

0 commit comments

Comments
 (0)