Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions benchmarks/AutoPersistBenchmark.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using System;
using System.Collections.ObjectModel;
using System.Reactive;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Order;

namespace ReactiveUI.Benchmarks
{
[ClrJob]
[CoreJob]
[MemoryDiagnoser]
[MarkdownExporterAttribute.GitHub]
public class AutoPersistBenchmark
{
private ReactiveList<MockViewModel> _collection;

[GlobalSetup]
public void Setup()
{
_collection = new ReactiveList<MockViewModel>(new[]
{
new MockViewModel(),
new MockViewModel(),
new MockViewModel(),
new MockViewModel(),
new MockViewModel(),
});
}

[Benchmark]
public void AutoPersistCollection()
{
var disposable = _collection.AutoPersistCollection(x => Observable.Create<Unit>(_ =>
{
Console.WriteLine("Done stuff");
return Disposable.Empty;
}).Select(_ => Unit.Default), TimeSpan.FromMilliseconds(200));

for (int i = 0; i < 5; ++i)
{
_collection.Add(new MockViewModel());
}

_collection.Clear();

disposable.Dispose();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@
using System.Collections.ObjectModel;
using System.Linq;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Attributes.Exporters;
using BenchmarkDotNet.Attributes.Jobs;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Order;
using BenchmarkDotNet.Toolchains.CsProj;
using DynamicData;

namespace ReactiveUI.Benchmarks
#pragma warning disable CS0618 // Item is obsolete warning

namespace ReactiveUI.Benchmarks.Legacy
{
[ClrJob]
[CoreJob]
[MemoryDiagnoser]
[MarkdownExporterAttribute.GitHub]
public class CreateReactiveListBenchmark
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
using System;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq.Expressions;
using System.Runtime.CompilerServices;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Attributes.Columns;
using BenchmarkDotNet.Attributes.Exporters;
using BenchmarkDotNet.Attributes.Jobs;
using BenchmarkDotNet.Order;

namespace ReactiveUI.Benchmarks
{
[ClrJob]
[CoreJob]
[MonoJob]
[RPlotExporter]
[RankColumn]
[MemoryDiagnoser]
[MarkdownExporterAttribute.GitHub]
public class INPCObservableForPropertyBenchmarks
{
Expand All @@ -37,7 +33,8 @@ public void PropertyBinding()
var testClass = new TestClassChanged();

var changes = new List<IObservedChange<object, object>>();
instance.GetNotificationForProperty(testClass, exp, propertyName, false).Subscribe(c => changes.Add(c));
var dispose = instance.GetNotificationForProperty(testClass, exp, propertyName, false).Subscribe(c => changes.Add(c));
dispose.Dispose();
}

private class TestClassChanged : INotifyPropertyChanged
Expand Down Expand Up @@ -70,8 +67,7 @@ public string Property2

public void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
var handler = PropertyChanged;
if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
namespace ReactiveUI.Benchmarks
using System.Runtime.Serialization;

namespace ReactiveUI.Benchmarks
{
[DataContract]
public class MockViewModel : ReactiveObject, IRoutableViewModel
{
public IScreen HostScreen { get; }
Expand Down
82 changes: 82 additions & 0 deletions benchmarks/NavigationStackBenchmark.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
using System;
using System.Linq;
using System.Reactive.Concurrency;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Order;

namespace ReactiveUI.Benchmarks
{
[ClrJob]
[CoreJob]
[MemoryDiagnoser]
[MarkdownExporterAttribute.GitHub]
public class NavigationStackBenchmark
{
private static readonly Func<MockViewModel> _mockViewModel;
private RoutingState _router;

static NavigationStackBenchmark()
{
_mockViewModel = () => new MockViewModel();
}

[GlobalCleanup]
public void Cleanup()
{
_router.NavigationStack.Clear();
_router = null;
}

[IterationSetup]
public void IterationSetup()
{
_router.NavigationStack.Clear();
}

[Benchmark]
public void Navigate()
{
using (_router.Navigate.Execute(_mockViewModel()).Subscribe())
{
_router.NavigationStack.ToList();
}
}

[Benchmark]
public void NavigateAndReset()
{
using (_router.NavigateAndReset.Execute(_mockViewModel()).Subscribe())
{
_router.NavigationStack.ToList();
}
}

[Benchmark]
public void NavigateBack()
{
using (_router.NavigateAndReset.Execute(_mockViewModel()).Subscribe())
using (_router.Navigate.Execute(_mockViewModel()).Subscribe())
using (_router.NavigateBack.Execute().Subscribe())
{
}
}

[Benchmark]
public void NavigationStack()
{
using (_router.NavigateAndReset.Execute(_mockViewModel()).Subscribe())
{
_router.NavigationStack.ToList();
}
}

[Benchmark]
public void RoutingState() => new RoutingState();

[GlobalSetup]
public void Setup()
{
_router = new RoutingState(ImmediateScheduler.Instance);
}
}
}
14 changes: 14 additions & 0 deletions benchmarks/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BenchmarkDotNet.Running;

namespace ReactiveUI.Benchmarks
{
class Program
{
static void Main(string[] args) => BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args);
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Attributes.Exporters;
using BenchmarkDotNet.Attributes.Jobs;
using BenchmarkDotNet.Order;
using DynamicData;

namespace ReactiveUI.Benchmarks
#pragma warning disable CS0618 // Item is obsolete warning

namespace ReactiveUI.Benchmarks.Legacy
{
[ClrJob]
[CoreJob]
[MemoryDiagnoser]
[MarkdownExporterAttribute.GitHub]
public class ReactiveListOperationBenchmark
{
Expand All @@ -17,6 +20,12 @@ public void Setup()
_reactiveList = new ReactiveList<string>();
}

[IterationSetup]
public void SetupIteration()
{
_reactiveList.Clear();
}

[GlobalCleanup]
public void Teardown()
{
Expand Down Expand Up @@ -53,7 +62,7 @@ public void AddOrInsertRange() => _reactiveList.AddOrInsertRange(new[]
}, -1);

[Benchmark]
public void Insert() => _reactiveList.Insert(1, "ReactiveUI.Benchmarks");
public void Insert() => _reactiveList.Insert(0, "ReactiveUI.Benchmarks");

[Benchmark]
public void RemoveItem() => _reactiveList.Remove("ReactiveUI");
Expand Down
29 changes: 29 additions & 0 deletions benchmarks/ReactiveUI.Benchmarks.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<IsPackable>false</IsPackable>
<TargetFrameworks>net461;netcoreapp2.0</TargetFrameworks>
<PackageId>BenchmarkDotNet.Samples</PackageId>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<DebugSymbols>true</DebugSymbols>
<OutputType>Exe</OutputType>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="DynamicData" Version="6.4.0.2419" />
<PackageReference Include="BenchmarkDotNet" Version="0.11.1" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFrameworkIdentifier)' == '.NETFramework' ">
<Reference Include="System.Reflection" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\src\ReactiveUI\ReactiveUI.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="xunit.runner.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion benchmarks/ReactiveUI.Benchmarks.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27703.2000
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ReactiveUI.Benchmarks", "ReactiveUI.Benchmarks\ReactiveUI.Benchmarks.csproj", "{EC6DD0F1-4D99-4BE8-B3F1-1DD71D86C24A}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ReactiveUI.Benchmarks", "ReactiveUI.Benchmarks.csproj", "{EC6DD0F1-4D99-4BE8-B3F1-1DD71D86C24A}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "benchmarks", "benchmarks", "{0DB2C65F-BE8F-4021-8860-D2D6EB9DD80A}"
EndProject
Expand Down
31 changes: 0 additions & 31 deletions benchmarks/ReactiveUI.Benchmarks/AutoPersistBenchmark.cs

This file was deleted.

45 changes: 0 additions & 45 deletions benchmarks/ReactiveUI.Benchmarks/Harness.cs

This file was deleted.

Loading