Skip to content

Commit e711cd2

Browse files
committed
PR feedback
1 parent beec751 commit e711cd2

File tree

5 files changed

+31
-35
lines changed

5 files changed

+31
-35
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ class BenchCase
2121
{
2222
public string Id = "";
2323
public string Query = "";
24-
public IList<string> Signals = new List<string>();
24+
public string SignalExpression = "";
2525
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace SeqCli.Cli.Commands;
2424
*/
2525
class BenchCaseTimings
2626
{
27-
List<double> _elaspseds = new() { };
27+
readonly List<double> _elaspseds = new() { };
2828
public double MeanElapsed => _elaspseds.Sum() / _elaspseds.Count;
2929
public double MinElapsed => _elaspseds.Min();
3030
public double MaxElapsed => _elaspseds.Max();

src/SeqCli/Cli/Commands/Bench/BenchCases.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,24 @@
22
"cases": [
33
{
44
"id": "count-star",
5-
"query": "select count(*) from stream",
6-
"signals": []
5+
"query": "select count(*) from stream"
76
},
87
{
98
"id": "starts-with",
10-
"query": "select count(*) from stream where @Message like '%abcde'",
11-
"signals": []
9+
"query": "select count(*) from stream where @Message like '%abcde'"
1210
},
1311
{
1412
"id": "without-signal",
13+
"query": "select count(*) from stream where @Level = 'Warning'"
14+
},
15+
{
16+
"id": "with-signal",
1517
"query": "select count(*) from stream where @Level = 'Warning'",
16-
"signals": []
18+
"signalExpression": ""
1719
},
1820
{
1921
"id": "property-match",
20-
"query": "select count(*) from stream where Action = 'ListAsync'",
21-
"signals": []
22+
"query": "select count(*) from stream where Action = 'ListAsync'"
2223
}
2324
]
2425
}

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

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ namespace SeqCli.Cli.Commands;
6969
{
7070
""id"": ""count-star"",
7171
""query"": ""select count(*) from stream"",
72-
""signals"": [""signal-id-here""]
72+
""signalExpression"": ""signal-expression-here""]
7373
}
7474
]
7575
}
@@ -83,7 +83,6 @@ class BenchCommand : Command
8383
string _cases = "";
8484
string _reportingServerUrl = "";
8585
string _reportingServerApiKey = "";
86-
ILogger? _reportingLogger = null;
8786

8887
public BenchCommand(SeqConnectionFactory connectionFactory)
8988
{
@@ -116,7 +115,7 @@ protected override async Task<int> Run()
116115
try
117116
{
118117
var connection = _connectionFactory.Connect(_connection);
119-
_reportingLogger = BuildReportingLogger();
118+
using var reportingLogger = BuildReportingLogger();
120119
var cases = ReadCases(_cases);
121120
var runId = Guid.NewGuid().ToString("N").Substring(0, 4);
122121
var start = _range.Start ?? DateTime.UtcNow.AddDays(-7);
@@ -131,9 +130,9 @@ protected override async Task<int> Run()
131130
{
132131
var response = await connection.Data.QueryAsync(
133132
c.Query,
134-
_range.Start ?? DateTime.UtcNow.AddDays(-7),
135-
_range.End,
136-
SignalExpressionPart.FromIntersectedIds(c.Signals)
133+
start,
134+
end,
135+
SignalExpressionPart.Signal(c.SignalExpression)
137136
);
138137

139138
timings.PushElapsed(response.Statistics.ElapsedMilliseconds);
@@ -149,14 +148,14 @@ protected override async Task<int> Run()
149148
using (LogContext.PushProperty("MinElapsed", timings.MinElapsed))
150149
using (LogContext.PushProperty("MaxElapsed", timings.MaxElapsed))
151150
using (LogContext.PushProperty("Runs", _runs))
152-
using (LogContext.PushProperty("Signals", c.Signals))
151+
using (LogContext.PushProperty("Signals", c.SignalExpression))
153152
using (LogContext.PushProperty("Start", start))
154153
using (LogContext.PushProperty("StandardDeviationElapsed", timings.StandardDeviationElapsed))
155154
using (end != null ? LogContext.PushProperty("End", end) : null)
156155
using (LogContext.PushProperty("Query", c.Query))
157156
{
158-
_reportingLogger.Information(
159-
"Bench run {BenchRunId} for query {Id}. Mean {MeanElapsed:N0} ms with relative dispersion {RelativeStandardDeviationElapsed:N2}",
157+
reportingLogger.Information(
158+
"Bench run {BenchRunId} for query {Id}: mean {MeanElapsed:N0} ms with relative dispersion {RelativeStandardDeviationElapsed:N2}",
160159
runId, c.Id,
161160
timings.MeanElapsed,
162161
timings.RelativeStandardDeviationElapsed);
@@ -175,20 +174,18 @@ protected override async Task<int> Run()
175174
/// Build a second Serilog logger for logging benchmark results.
176175
/// </summary>
177176
Logger BuildReportingLogger()
178-
{
179-
return string.IsNullOrWhiteSpace(_reportingServerUrl)
180-
? new LoggerConfiguration()
181-
.Enrich.FromLogContext()
182-
.WriteTo.Console()
183-
.CreateLogger()
184-
: new LoggerConfiguration()
185-
.Enrich.FromLogContext()
186-
.WriteTo.Console()
187-
.WriteTo.Seq(
188-
_reportingServerUrl,
189-
apiKey: string.IsNullOrWhiteSpace(_reportingServerApiKey) ? null : _reportingServerApiKey,
190-
period: TimeSpan.FromMilliseconds(1))
191-
.CreateLogger();
177+
{
178+
var loggerConfiguration = new LoggerConfiguration()
179+
.Enrich.FromLogContext()
180+
.WriteTo.Console();
181+
182+
if (!string.IsNullOrWhiteSpace(_reportingServerUrl))
183+
loggerConfiguration.WriteTo.Seq(
184+
_reportingServerUrl,
185+
apiKey: string.IsNullOrWhiteSpace(_reportingServerApiKey) ? null : _reportingServerApiKey,
186+
period: TimeSpan.FromMilliseconds(1));
187+
188+
return loggerConfiguration.CreateLogger();
192189
}
193190

194191
/// <summary>

src/SeqCli/SeqCli.csproj

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<TreatSpecificWarningsAsErrors />
1111
<PackAsTool>true</PackAsTool>
1212
<ToolCommandName>seqcli</ToolCommandName>
13+
<LangVersion>default</LangVersion>
1314
</PropertyGroup>
1415
<ItemGroup>
1516
<Content Include="..\..\asset\SeqCli.ico" Link="SeqCli.ico" />
@@ -46,7 +47,4 @@
4647
<ItemGroup>
4748
<ProjectReference Include="..\Roastery\Roastery.csproj" />
4849
</ItemGroup>
49-
<ItemGroup>
50-
<Compile Remove="Bench\JsonCaseReader.cs" />
51-
</ItemGroup>
5250
</Project>

0 commit comments

Comments
 (0)