StopwatchTest.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. using System;
  5. using System.Reactive.Concurrency;
  6. using System.Threading;
  7. using Xunit;
  8. namespace ReactiveTests.Tests
  9. {
  10. static class StopwatchTest
  11. {
  12. public static void Run(IStopwatchProvider stopwatchProvider)
  13. {
  14. /*
  15. * TODO: Temporarily disabled until we iron out all of the scheduler improvements.
  16. */
  17. //var N = 10;
  18. //var t = default(long);
  19. //var d = 1;
  20. //for (int i = 0; i < N; i++)
  21. //{
  22. // var sw = stopwatchProvider.StartStopwatch();
  23. // var e1 = sw.Elapsed;
  24. // Thread.Sleep(d);
  25. // var e2 = sw.Elapsed;
  26. // Assert.True(e2.Ticks > e1.Ticks);
  27. // t += (e2 - e1).Ticks;
  28. // sw.Dispose();
  29. //}
  30. //Assert.True(TimeSpan.FromTicks(t / N).TotalMilliseconds < d * 10 /* 10x margin */);
  31. }
  32. }
  33. }