Skip to content

Commit 380bdfb

Browse files
authored
Merge pull request #382 from liammclennan/increase-timeout-for-bench
Add `--timeout` option to bench command
2 parents 3609645 + dfdd8d8 commit 380bdfb

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,14 @@ class BenchCommand : Command
6969
int _runs = 10;
7070
readonly ConnectionFeature _connection;
7171
readonly DateRangeFeature _range;
72+
readonly TimeoutFeature _timeout;
7273
string _cases = "";
7374
string _reportingServerUrl = "";
7475
string _reportingServerApiKey = "";
7576
string _description = "";
7677
bool _withIngestion = false;
7778
bool _withQueries = false;
78-
79+
7980
public BenchCommand(SeqConnectionFactory connectionFactory)
8081
{
8182
_connectionFactory = connectionFactory;
@@ -88,6 +89,7 @@ public BenchCommand(SeqConnectionFactory connectionFactory)
8889

8990
_connection = Enable<ConnectionFeature>();
9091
_range = Enable<DateRangeFeature>();
92+
_timeout = Enable<TimeoutFeature>();
9193

9294
Options.Add(
9395
"reporting-server=",
@@ -123,6 +125,7 @@ protected override async Task<int> Run()
123125
{
124126
var (_, apiKey) = _connectionFactory.GetConnectionDetails(_connection);
125127
var connection = _connectionFactory.Connect(_connection);
128+
var timeout = _timeout.ApplyTimeout(connection.Client.HttpClient);
126129
var seqVersion = (await connection.Client.GetRootAsync()).Version;
127130
await using var reportingLogger = BuildReportingLogger();
128131

@@ -194,7 +197,7 @@ protected override async Task<int> Run()
194197

195198
if (_withQueries)
196199
{
197-
var collectedTimings = await QueryBenchmark(reportingLogger, runId, connection, seqVersion);
200+
var collectedTimings = await QueryBenchmark(reportingLogger, runId, connection, seqVersion, timeout);
198201
collectedTimings.LogSummary(_description);
199202
cancellationTokenSource.Cancel();
200203
}
@@ -231,7 +234,8 @@ async Task IngestionBenchmark(Logger reportingLogger, string runId, SeqConnectio
231234
}
232235
}
233236

234-
async Task<QueryBenchRunResults> QueryBenchmark(Logger reportingLogger, string runId, SeqConnection connection, string seqVersion)
237+
async Task<QueryBenchRunResults> QueryBenchmark(Logger reportingLogger, string runId, SeqConnection connection,
238+
string seqVersion, TimeSpan? timeout)
235239
{
236240
var cases = ReadCases(_cases);
237241
QueryBenchRunResults queryBenchRunResults = new(reportingLogger);
@@ -254,7 +258,7 @@ async Task<QueryBenchRunResults> QueryBenchmark(Logger reportingLogger, string r
254258
_range.End,
255259
c.SignalExpression != null ? SignalExpressionPart.Signal(c.SignalExpression) : null,
256260
null,
257-
TimeSpan.FromMinutes(4)
261+
timeout
258262
);
259263

260264
timings.PushElapsed(response.Statistics.ElapsedMilliseconds);

0 commit comments

Comments
 (0)