1
0

SwitchBenchmark.cs 706 B

12345678910111213141516171819202122232425
  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.Reactive.Linq;
  5. using BenchmarkDotNet.Attributes;
  6. using System.Reactive.Threading.Tasks;
  7. using System.Threading.Tasks;
  8. namespace Benchmarks.System.Reactive
  9. {
  10. [MemoryDiagnoser]
  11. public class SwitchBenchmark
  12. {
  13. [Benchmark]
  14. public async Task Switch_10000_Sources()
  15. {
  16. await Observable
  17. .Range(1, 10000)
  18. .Select(x => Observable.Return(x))
  19. .Switch()
  20. .ToTask();
  21. }
  22. }
  23. }