Skip to content

Commit 75c7289

Browse files
committed
Comments
1 parent 2a2598b commit 75c7289

File tree

3 files changed

+11
-14
lines changed

3 files changed

+11
-14
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,15 @@
1919

2020
namespace SeqCli.Cli.Commands;
2121

22+
/*
23+
* Collects benchmarking elapsed time measurements and calculates statistics.
24+
*/
2225
class BenchCaseTimings
2326
{
2427
List<double> _elaspseds = new() { };
25-
2628
public double MeanElapsed => _elaspseds.Sum() / _elaspseds.Count;
2729
public double MinElapsed => _elaspseds.Min();
2830
public double MaxElapsed => _elaspseds.Max();
29-
3031
public double StandardDeviationElapsed => StandardDeviation(_elaspseds);
3132
public double RelativeStandardDeviationElapsed => StandardDeviation(_elaspseds) / MeanElapsed;
3233

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

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,26 +77,20 @@ namespace SeqCli.Cli.Commands;
7777
class BenchCommand : Command
7878
{
7979
readonly SeqConnectionFactory _connectionFactory;
80-
int _runs = 0;
80+
int _runs = 3;
8181
readonly ConnectionFeature _connection;
8282
readonly DateRangeFeature _range;
8383
string _cases = "";
8484
string _reportingServerUrl = "";
8585
string _reportingServerApiKey = "";
8686
ILogger? _reportingLogger = null;
8787

88-
const int DefaultRuns = 3;
89-
9088
public BenchCommand(SeqConnectionFactory connectionFactory)
9189
{
9290
_connectionFactory = connectionFactory;
93-
_runs = DefaultRuns;
9491
Options.Add("r|runs=", "The number of runs to execute", r =>
9592
{
96-
if (!int.TryParse(r, out _runs))
97-
{
98-
_runs = DefaultRuns;
99-
}
93+
int.TryParse(r, out _runs);
10094
});
10195

10296
Options.Add(
@@ -123,7 +117,6 @@ protected override async Task<int> Run()
123117
{
124118
var connection = _connectionFactory.Connect(_connection);
125119
_reportingLogger = BuildReportingLogger();
126-
127120
var cases = ReadCases(_cases);
128121
var runId = Guid.NewGuid().ToString("N").Substring(0, 4);
129122
var start = _range.Start ?? DateTime.UtcNow.AddDays(-7);
@@ -178,6 +171,9 @@ protected override async Task<int> Run()
178171
}
179172
}
180173

174+
/// <summary>
175+
/// Build a second Serilog logger for logging benchmark results.
176+
/// </summary>
181177
Logger BuildReportingLogger()
182178
{
183179
return string.IsNullOrWhiteSpace(_reportingServerUrl)
@@ -195,6 +191,9 @@ Logger BuildReportingLogger()
195191
.CreateLogger();
196192
}
197193

194+
/// <summary>
195+
/// Read and parse the bench test cases from the file supplied or else from a default file.
196+
/// </summary>
198197
static BenchCasesCollection ReadCases(string filename)
199198
{
200199
var defaultCasesPath = Path.Combine(Path.GetDirectoryName(typeof(BenchCommand).Assembly.Location)!, "Cli/Commands/Bench/BenchCases.json");

src/SeqCli/SeqCli.csproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@
4646
<ItemGroup>
4747
<ProjectReference Include="..\Roastery\Roastery.csproj" />
4848
</ItemGroup>
49-
<ItemGroup>
50-
<Folder Include="Bench" />
51-
</ItemGroup>
5249
<ItemGroup>
5350
<Compile Remove="Bench\JsonCaseReader.cs" />
5451
</ItemGroup>

0 commit comments

Comments
 (0)