BenchmarkInterop.cs 785 B

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