Skip to content

Commit 8330eb8

Browse files
ljmcgjbrinkman
andauthored
Update C# benchmark Program.cs to fix benchmark timing collection. (#4478)
Update benchmark timing collection code in RedisBenchmark to better use Stopwatch. Changed use of Stopwatch.Start() to Stopwatch.Restart(). The Restart() method zeroes out the timer for each iteration. The prior code would accumulate time across all iterations. Converted the time collection to use Stopwatch.Elapsed.TotalMilliseconds, as this provides a double value and is the proper value to use in this case. Signed-off-by: L Joseph McGuinness <ljosephmcguinness@gmail.com> Co-authored-by: Joseph Brinkman <joe.brinkman@improving.com>
1 parent 280b910 commit 8330eb8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

benchmarks/csharp/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ private static async Task RedisBenchmark(
123123
int index = (int)(s_started_tasks_counter % clients.Length);
124124
ClientWrapper client = clients[index];
125125
ChosenAction action = ChooseAction();
126-
stopwatch.Start();
126+
stopwatch.Restart();
127127
switch (action)
128128
{
129129
case ChosenAction.GET_EXISTING:
@@ -140,7 +140,7 @@ private static async Task RedisBenchmark(
140140
}
141141
stopwatch.Stop();
142142
ConcurrentBag<double> latency_list = action_latencies[action];
143-
latency_list.Add(((double)stopwatch.ElapsedMilliseconds) / 1000);
143+
latency_list.Add(stopwatch.Elapsed.TotalMilliseconds);
144144
} while (s_started_tasks_counter < total_commands);
145145
}
146146

0 commit comments

Comments
 (0)