Skip to content

Commit 49fc4f1

Browse files
authored
Fix benchmark client incorrectly measuring warmup RPS (#1007)
1 parent 634fda1 commit 49fc4f1

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

perf/benchmarkapps/GrpcAspNetCoreServer/Program.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,14 @@ public static IHostBuilder CreateHostBuilder(string[] args)
110110
if (Enum.TryParse<LogLevel>(config["LogLevel"], out var logLevel) && logLevel != LogLevel.None)
111111
{
112112
Console.WriteLine($"Console Logging enabled with level '{logLevel}'");
113-
loggerFactory.AddConsole(o => o.TimestampFormat = "ss.ffff ").SetMinimumLevel(logLevel);
113+
114+
loggerFactory
115+
#if NETCOREAPP3_1
116+
.AddConsole(o => o.TimestampFormat = "ss.ffff ")
117+
#else
118+
.AddSimpleConsole(o => o.TimestampFormat = "ss.ffff ")
119+
#endif
120+
.SetMinimumLevel(logLevel);
114121
}
115122
})
116123
.UseDefaultServiceProvider((context, options) =>

perf/benchmarkapps/GrpcClient/Program.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ class Program
4848
private static List<List<double>> _latencyPerConnection = null!;
4949
private static double _maxLatency;
5050
private static Stopwatch _workTimer = new Stopwatch();
51-
private static bool _warmingUp;
52-
private static bool _stopped;
51+
private static volatile bool _warmingUp;
52+
private static volatile bool _stopped;
5353
private static SemaphoreSlim _lock = new SemaphoreSlim(1);
5454
private static List<(double sum, int count)> _latencyAverage = null!;
5555
private static int _totalRequests;
@@ -112,6 +112,7 @@ private static async Task StartScenario()
112112
var cts = new CancellationTokenSource();
113113
cts.CancelAfter(TimeSpan.FromSeconds(_options.Duration + _options.Warmup));
114114

115+
_warmingUp = true;
115116
_ = Task.Run(async () =>
116117
{
117118
await Task.Delay(TimeSpan.FromSeconds(_options.Warmup));

0 commit comments

Comments
 (0)