From 256fc2d2fec5e1dee3393f58168e1e193ae9871f Mon Sep 17 00:00:00 2001 From: Michael Maxwell Date: Wed, 22 Sep 2021 17:35:15 -0400 Subject: [PATCH] Use `Stopwatch.StartNew()` (#2403) --- test/OpenTelemetry.Tests/Metrics/MetricAPITest.cs | 6 ++---- test/StressTestMetrics/Program.cs | 3 +-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/test/OpenTelemetry.Tests/Metrics/MetricAPITest.cs b/test/OpenTelemetry.Tests/Metrics/MetricAPITest.cs index 668a6aa1328..f2e06df3a31 100644 --- a/test/OpenTelemetry.Tests/Metrics/MetricAPITest.cs +++ b/test/OpenTelemetry.Tests/Metrics/MetricAPITest.cs @@ -284,8 +284,7 @@ void ProcessExport(Batch batch) // Block until all threads started. mreToEnsureAllThreadsStarted.WaitOne(); - Stopwatch sw = new Stopwatch(); - sw.Start(); + Stopwatch sw = Stopwatch.StartNew(); // unblock all the threads. // (i.e let them start counter.Add) @@ -354,8 +353,7 @@ void ProcessExport(Batch batch) // Block until all threads started. mreToEnsureAllThreadsStarted.WaitOne(); - Stopwatch sw = new Stopwatch(); - sw.Start(); + Stopwatch sw = Stopwatch.StartNew(); // unblock all the threads. // (i.e let them start counter.Add) diff --git a/test/StressTestMetrics/Program.cs b/test/StressTestMetrics/Program.cs index bd2e102f957..872fb4af49e 100644 --- a/test/StressTestMetrics/Program.cs +++ b/test/StressTestMetrics/Program.cs @@ -38,8 +38,7 @@ public static void Main(string[] args) using var meterProvider = Sdk.CreateMeterProviderBuilder() .AddSource("TestMeter") .Build(); - Stopwatch sw = new Stopwatch(); - sw.Start(); + Stopwatch sw = Stopwatch.StartNew(); Parallel.Invoke( () =>