diff --git a/Rx.NET/ComparisonBenchmarks/ComparisonBenchmarks.sln b/Rx.NET/ComparisonBenchmarks/ComparisonBenchmarks.sln new file mode 100644 index 0000000000..d6c7a600d7 --- /dev/null +++ b/Rx.NET/ComparisonBenchmarks/ComparisonBenchmarks.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.27703.2035 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComparisonBenchmarks", "ComparisonBenchmarks\ComparisonBenchmarks.csproj", "{50DDB92A-793F-43DF-A84E-1759A235A15D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {50DDB92A-793F-43DF-A84E-1759A235A15D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {50DDB92A-793F-43DF-A84E-1759A235A15D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {50DDB92A-793F-43DF-A84E-1759A235A15D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {50DDB92A-793F-43DF-A84E-1759A235A15D}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {643F4DF5-5DD7-4AFB-A95E-29414DDA9379} + EndGlobalSection +EndGlobal diff --git a/Rx.NET/ComparisonBenchmarks/ComparisonBenchmarks/ComparisonBenchmarks.csproj b/Rx.NET/ComparisonBenchmarks/ComparisonBenchmarks/ComparisonBenchmarks.csproj new file mode 100644 index 0000000000..cca404d8fa --- /dev/null +++ b/Rx.NET/ComparisonBenchmarks/ComparisonBenchmarks/ComparisonBenchmarks.csproj @@ -0,0 +1,14 @@ + + + + Exe + netcoreapp2.1 + latest + + + + + + + + diff --git a/Rx.NET/ComparisonBenchmarks/ComparisonBenchmarks/Program.cs b/Rx.NET/ComparisonBenchmarks/ComparisonBenchmarks/Program.cs new file mode 100644 index 0000000000..9d517ec9f1 --- /dev/null +++ b/Rx.NET/ComparisonBenchmarks/ComparisonBenchmarks/Program.cs @@ -0,0 +1,22 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using BenchmarkDotNet.Running; + +namespace ComparisonBenchmarks +{ + internal class Program + { + static void Main(string[] args) + { + var switcher = new BenchmarkSwitcher(new[] { + typeof(RangeBenchmark) + }); + + switcher.Run(); + Console.ReadLine(); + } + } +} diff --git a/Rx.NET/ComparisonBenchmarks/ComparisonBenchmarks/RangeBenchmark.cs b/Rx.NET/ComparisonBenchmarks/ComparisonBenchmarks/RangeBenchmark.cs new file mode 100644 index 0000000000..d732fb35f8 --- /dev/null +++ b/Rx.NET/ComparisonBenchmarks/ComparisonBenchmarks/RangeBenchmark.cs @@ -0,0 +1,25 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. + +using System; +using System.Reactive.Linq; +using System.Threading; +using BenchmarkDotNet.Attributes; + +namespace ComparisonBenchmarks +{ + [MemoryDiagnoser] + public class RangeBenchmark + { + [Params(1, 10, 100, 1000, 10000, 100000, 1000000)] + public int N; + private int _store; + + [Benchmark] + public void Range() + { + Observable.Range(1, N).Subscribe(v => Volatile.Write(ref _store, v)); + } + } +}