Skip to content

Commit dfdd8d8

Browse files
committed
Add TimeoutFeature to bench command.
1 parent b510944 commit dfdd8d8

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

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

Lines changed: 8 additions & 5 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,7 +125,7 @@ protected override async Task<int> Run()
123125
{
124126
var (_, apiKey) = _connectionFactory.GetConnectionDetails(_connection);
125127
var connection = _connectionFactory.Connect(_connection);
126-
connection.Client.HttpClient.Timeout = TimeSpan.FromMinutes(4);
128+
var timeout = _timeout.ApplyTimeout(connection.Client.HttpClient);
127129
var seqVersion = (await connection.Client.GetRootAsync()).Version;
128130
await using var reportingLogger = BuildReportingLogger();
129131

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

196198
if (_withQueries)
197199
{
198-
var collectedTimings = await QueryBenchmark(reportingLogger, runId, connection, seqVersion);
200+
var collectedTimings = await QueryBenchmark(reportingLogger, runId, connection, seqVersion, timeout);
199201
collectedTimings.LogSummary(_description);
200202
cancellationTokenSource.Cancel();
201203
}
@@ -232,7 +234,8 @@ async Task IngestionBenchmark(Logger reportingLogger, string runId, SeqConnectio
232234
}
233235
}
234236

235-
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)
236239
{
237240
var cases = ReadCases(_cases);
238241
QueryBenchRunResults queryBenchRunResults = new(reportingLogger);
@@ -255,7 +258,7 @@ async Task<QueryBenchRunResults> QueryBenchmark(Logger reportingLogger, string r
255258
_range.End,
256259
c.SignalExpression != null ? SignalExpressionPart.Signal(c.SignalExpression) : null,
257260
null,
258-
TimeSpan.FromMinutes(4)
261+
timeout
259262
);
260263

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

0 commit comments

Comments
 (0)