StopwatchTest.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the Apache 2.0 License.
  3. // See the LICENSE file in the project root for more information.
  4. #if !NO_STOPWATCH
  5. using System;
  6. using System.Reactive.Concurrency;
  7. using System.Threading;
  8. using Xunit;
  9. namespace ReactiveTests.Tests
  10. {
  11. static class StopwatchTest
  12. {
  13. public static void Run(IStopwatchProvider stopwatchProvider)
  14. {
  15. /*
  16. * TODO: Temporarily disabled until we iron out all of the scheduler improvements.
  17. */
  18. //var N = 10;
  19. //var t = default(long);
  20. //var d = 1;
  21. //for (int i = 0; i < N; i++)
  22. //{
  23. // var sw = stopwatchProvider.StartStopwatch();
  24. // var e1 = sw.Elapsed;
  25. // Thread.Sleep(d);
  26. // var e2 = sw.Elapsed;
  27. // Assert.True(e2.Ticks > e1.Ticks);
  28. // t += (e2 - e1).Ticks;
  29. // sw.Dispose();
  30. //}
  31. //Assert.True(TimeSpan.FromTicks(t / N).TotalMilliseconds < d * 10 /* 10x margin */);
  32. }
  33. }
  34. }
  35. #endif