1
0

IgnoreElementsBenchmark.cs 772 B

1234567891011121314151617181920212223242526272829
  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.Linq;
  7. using System.Threading;
  8. using BenchmarkDotNet.Attributes;
  9. namespace Benchmarks.System.Interactive
  10. {
  11. [MemoryDiagnoser]
  12. public class IgnoreElementsBenchmark
  13. {
  14. [Params(1, 10, 100, 1000, 10000, 100000, 1000000)]
  15. public int N;
  16. private int _store;
  17. [Benchmark]
  18. public void Ignore()
  19. {
  20. Enumerable.Range(1, N)
  21. .IgnoreElements()
  22. .Subscribe(v => Volatile.Write(ref _store, v));
  23. }
  24. }
  25. }