-
Notifications
You must be signed in to change notification settings - Fork 751
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Less allocations in CombineLatest (#637)
* Add a benchmark runner with some initial benchmarks for the Zip and CombineLatest-operators. * Save the allocations of SingleAssignmentDisposables in the n-ary CombineLatest-operators (for n >= 3).
- Loading branch information
1 parent
d00c7c5
commit fbce075
Showing
8 changed files
with
615 additions
and
348 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
Rx.NET/Source/benchmarks/Benchmarks.System.Reactive/Benchmarks.System.Reactive.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net46</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="BenchmarkDotNet" Version="0.10.14" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\tests\Tests.System.Reactive\Tests.System.Reactive.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
105 changes: 105 additions & 0 deletions
105
Rx.NET/Source/benchmarks/Benchmarks.System.Reactive/CombineLatestBenchmark.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
// 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 BenchmarkDotNet.Attributes; | ||
using ReactiveTests.Tests; | ||
|
||
namespace Benchmarks.System.Reactive | ||
{ | ||
[MemoryDiagnoser] | ||
public class CombineLatestBenchmark | ||
{ | ||
private CombineLatestTest _zipTest = new CombineLatestTest(); | ||
|
||
[Benchmark] | ||
public void CombineLatest_Typical2() | ||
{ | ||
_zipTest.CombineLatest_Typical2(); | ||
} | ||
|
||
[Benchmark] | ||
public void CombineLatest_Typical3() | ||
{ | ||
_zipTest.CombineLatest_Typical3(); | ||
} | ||
|
||
[Benchmark] | ||
public void CombineLatest_Typical4() | ||
{ | ||
_zipTest.CombineLatest_Typical4(); | ||
} | ||
|
||
[Benchmark] | ||
public void CombineLatest_Typical5() | ||
{ | ||
_zipTest.CombineLatest_Typical5(); | ||
} | ||
|
||
[Benchmark] | ||
public void CombineLatest_Typical6() | ||
{ | ||
_zipTest.CombineLatest_Typical6(); | ||
} | ||
|
||
[Benchmark] | ||
public void CombineLatest_Typical7() | ||
{ | ||
_zipTest.CombineLatest_Typical7(); | ||
} | ||
|
||
[Benchmark] | ||
public void CombineLatest_Typical8() | ||
{ | ||
_zipTest.CombineLatest_Typical8(); | ||
} | ||
|
||
[Benchmark] | ||
public void CombineLatest_Typical9() | ||
{ | ||
_zipTest.CombineLatest_Typical9(); | ||
} | ||
|
||
[Benchmark] | ||
public void CombineLatest_Typical10() | ||
{ | ||
_zipTest.CombineLatest_Typical10(); | ||
} | ||
|
||
[Benchmark] | ||
public void CombineLatest_Typical11() | ||
{ | ||
_zipTest.CombineLatest_Typical11(); | ||
} | ||
|
||
[Benchmark] | ||
public void CombineLatest_Typical12() | ||
{ | ||
_zipTest.CombineLatest_Typical12(); | ||
} | ||
|
||
[Benchmark] | ||
public void CombineLatest_Typical13() | ||
{ | ||
_zipTest.CombineLatest_Typical13(); | ||
} | ||
|
||
[Benchmark] | ||
public void CombineLatest_Typical14() | ||
{ | ||
_zipTest.CombineLatest_Typical14(); | ||
} | ||
|
||
[Benchmark] | ||
public void CombineLatest_Typical15() | ||
{ | ||
_zipTest.CombineLatest_Typical15(); | ||
} | ||
|
||
[Benchmark] | ||
public void CombineLatest_Typical16() | ||
{ | ||
_zipTest.CombineLatest_Typical16(); | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
Rx.NET/Source/benchmarks/Benchmarks.System.Reactive/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// 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 Benchmarks.System.Reactive | ||
{ | ||
class Program | ||
{ | ||
static void Main() | ||
{ | ||
var switcher = new BenchmarkSwitcher(new[] { | ||
typeof(ZipBenchmark), | ||
typeof(CombineLatestBenchmark) | ||
}); | ||
|
||
switcher.Run(); | ||
Console.ReadLine(); | ||
} | ||
} | ||
} |
135 changes: 135 additions & 0 deletions
135
Rx.NET/Source/benchmarks/Benchmarks.System.Reactive/ZipBenchmark.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
// 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 BenchmarkDotNet.Attributes; | ||
using ReactiveTests.Tests; | ||
|
||
namespace Benchmarks.System.Reactive | ||
{ | ||
[MemoryDiagnoser] | ||
public class ZipBenchmark | ||
{ | ||
private ZipTest _zipTest = new ZipTest(); | ||
|
||
[Benchmark] | ||
public void Zip_NAry_Asymmetric() | ||
{ | ||
_zipTest.Zip_NAry_Asymmetric(); | ||
} | ||
|
||
[Benchmark] | ||
public void Zip_NAry_Asymmetric_Selector() | ||
{ | ||
_zipTest.Zip_NAry_Asymmetric_Selector(); | ||
} | ||
|
||
[Benchmark] | ||
public void Zip_NAry_Symmetric() | ||
{ | ||
_zipTest.Zip_NAry_Symmetric(); | ||
} | ||
|
||
[Benchmark] | ||
public void Zip_NAry_Symmetric_Selector() | ||
{ | ||
_zipTest.Zip_NAry_Symmetric_Selector(); | ||
} | ||
|
||
[Benchmark] | ||
public void Zip_NAry_Enumerable_Simple() | ||
{ | ||
_zipTest.Zip_NAry_Enumerable_Simple(); | ||
} | ||
|
||
[Benchmark] | ||
public void Zip_AllCompleted2() | ||
{ | ||
_zipTest.Zip_AllCompleted2(); | ||
} | ||
|
||
[Benchmark] | ||
public void Zip_AllCompleted3() | ||
{ | ||
_zipTest.Zip_AllCompleted3(); | ||
} | ||
|
||
[Benchmark] | ||
public void Zip_AllCompleted4() | ||
{ | ||
_zipTest.Zip_AllCompleted4(); | ||
} | ||
|
||
[Benchmark] | ||
public void Zip_AllCompleted5() | ||
{ | ||
_zipTest.Zip_AllCompleted5(); | ||
} | ||
|
||
[Benchmark] | ||
public void Zip_AllCompleted6() | ||
{ | ||
_zipTest.Zip_AllCompleted6(); | ||
} | ||
|
||
[Benchmark] | ||
public void Zip_AllCompleted7() | ||
{ | ||
_zipTest.Zip_AllCompleted7(); | ||
} | ||
|
||
[Benchmark] | ||
public void Zip_AllCompleted8() | ||
{ | ||
_zipTest.Zip_AllCompleted8(); | ||
} | ||
|
||
[Benchmark] | ||
public void Zip_AllCompleted9() | ||
{ | ||
_zipTest.Zip_AllCompleted9(); | ||
} | ||
|
||
[Benchmark] | ||
public void Zip_AllCompleted10() | ||
{ | ||
_zipTest.Zip_AllCompleted10(); | ||
} | ||
|
||
[Benchmark] | ||
public void Zip_AllCompleted11() | ||
{ | ||
_zipTest.Zip_AllCompleted11(); | ||
} | ||
|
||
[Benchmark] | ||
public void Zip_AllCompleted12() | ||
{ | ||
_zipTest.Zip_AllCompleted12(); | ||
} | ||
|
||
[Benchmark] | ||
public void Zip_AllCompleted13() | ||
{ | ||
_zipTest.Zip_AllCompleted13(); | ||
} | ||
|
||
[Benchmark] | ||
public void Zip_AllCompleted14() | ||
{ | ||
_zipTest.Zip_AllCompleted14(); | ||
} | ||
|
||
[Benchmark] | ||
public void Zip_AllCompleted15() | ||
{ | ||
_zipTest.Zip_AllCompleted15(); | ||
} | ||
|
||
[Benchmark] | ||
public void Zip_AllCompleted16() | ||
{ | ||
_zipTest.Zip_AllCompleted16(); | ||
} | ||
} | ||
} |
Oops, something went wrong.