From a33fae9a7f9a52038983c9b90e383d622db664f5 Mon Sep 17 00:00:00 2001 From: Michael Maxwell Date: Wed, 22 Sep 2021 14:57:54 -0400 Subject: [PATCH 1/2] Use `Stopwatch.StartNew()` --- test/StressTestMetrics/Program.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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( () => From 9a9a330f99245e4c5f4938038828ae0f2766d5dd Mon Sep 17 00:00:00 2001 From: Michael Maxwell Date: Wed, 22 Sep 2021 15:14:30 -0400 Subject: [PATCH 2/2] Update MetricAPITest.cs --- test/OpenTelemetry.Tests/Metrics/MetricAPITest.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 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)