BenchmarkInterop.cs 996 B

12345678910111213141516171819202122232425262728293031323334
  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.Collections.Generic;
  6. using System.Text;
  7. namespace Benchmarks.System.Interactive
  8. {
  9. /// <summary>
  10. /// Some helper extension methods to allow the same pattern to be used
  11. /// in both Rx and Ix benchmarks
  12. /// </summary>
  13. internal static class BenchmarkInterop
  14. {
  15. internal static void Subscribe<T>(this IEnumerable<T> enumerable, Action<T> onNext)
  16. {
  17. foreach (var v in enumerable)
  18. {
  19. onNext(v);
  20. }
  21. }
  22. internal static void Subscribe<T>(this IEnumerable<T> enumerable, Action<T> onNext, Action onCompleted)
  23. {
  24. foreach (var v in enumerable)
  25. {
  26. onNext(v);
  27. }
  28. onCompleted();
  29. }
  30. }
  31. }