-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/v2.0' into fixEventHandler
- Loading branch information
Showing
31 changed files
with
388 additions
and
86 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
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 @@ | ||
BenchmarkDotNet.Artifacts/ |
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,19 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFrameworks>netcoreapp2.2;net472</TargetFrameworks> | ||
<CodeAnalysisRuleSet>..\StreamJsonRpc.Tests\StreamJsonRpc.Tests.ruleset</CodeAnalysisRuleSet> | ||
<NoWarn>$(NoWarn);CS1591</NoWarn> | ||
<IsPackable>false</IsPackable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="BenchmarkDotNet" version="0.11.4" /> | ||
<PackageReference Include="BenchmarkDotNet.Diagnostics.Windows" Version="0.11.4" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\StreamJsonRpc\StreamJsonRpc.csproj" /> | ||
</ItemGroup> | ||
</Project> |
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,45 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace Benchmarks | ||
{ | ||
using System; | ||
using System.Threading.Tasks; | ||
using BenchmarkDotNet.Attributes; | ||
using Nerdbank.Streams; | ||
using StreamJsonRpc; | ||
|
||
[MemoryDiagnoser] | ||
public class InvokeBenchmarks | ||
{ | ||
private readonly JsonRpc clientRpc; | ||
private readonly JsonRpc serverRpc; | ||
|
||
public InvokeBenchmarks() | ||
{ | ||
var duplex = FullDuplexStream.CreatePipePair(); | ||
this.clientRpc = new JsonRpc(new HeaderDelimitedMessageHandler(duplex.Item1, new JsonMessageFormatter())); | ||
this.clientRpc.StartListening(); | ||
|
||
this.serverRpc = new JsonRpc(new HeaderDelimitedMessageHandler(duplex.Item2, new JsonMessageFormatter())); | ||
this.serverRpc.AddLocalRpcTarget(new Server()); | ||
this.serverRpc.StartListening(); | ||
} | ||
|
||
/// <summary> | ||
/// Workaround https://github.com/dotnet/BenchmarkDotNet/issues/837. | ||
/// </summary> | ||
[GlobalSetup] | ||
public void Workaround() => this.InvokeAsync_NoArgs(); | ||
|
||
[Benchmark] | ||
public Task InvokeAsync_NoArgs() => this.clientRpc.InvokeAsync(nameof(Server.NoOp), Array.Empty<object>()); | ||
|
||
private class Server | ||
{ | ||
public void NoOp() | ||
{ | ||
} | ||
} | ||
} | ||
} |
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,31 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace Benchmarks | ||
{ | ||
using System; | ||
using System.IO; | ||
using System.Threading.Tasks; | ||
using BenchmarkDotNet.Attributes; | ||
using StreamJsonRpc; | ||
|
||
[MemoryDiagnoser] | ||
public class NotifyBenchmarks | ||
{ | ||
private readonly JsonRpc clientRpc; | ||
|
||
public NotifyBenchmarks() | ||
{ | ||
this.clientRpc = new JsonRpc(Stream.Null); | ||
} | ||
|
||
/// <summary> | ||
/// Workaround https://github.com/dotnet/BenchmarkDotNet/issues/837. | ||
/// </summary> | ||
[GlobalSetup] | ||
public void Workaround() => this.NotifyAsync_NoArgs(); | ||
|
||
[Benchmark] | ||
public Task NotifyAsync_NoArgs() => this.clientRpc.NotifyAsync("NoOp", Array.Empty<object>()); | ||
} | ||
} |
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,33 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace Benchmarks | ||
{ | ||
using System; | ||
using System.Threading.Tasks; | ||
using BenchmarkDotNet.Running; | ||
|
||
internal static class Program | ||
{ | ||
private static async Task Main(string[] args) | ||
{ | ||
// Allow a special "manual" argument for convenient perfview.exe-monitored runs for GC pressure analysis. | ||
if (args.Length == 1 && args[0] == "manual") | ||
{ | ||
var b = new InvokeBenchmarks(); | ||
await b.InvokeAsync_NoArgs(); | ||
|
||
await Task.Delay(2000); | ||
|
||
for (int i = 0; i < 1000; i++) | ||
{ | ||
await b.InvokeAsync_NoArgs(); | ||
} | ||
} | ||
else | ||
{ | ||
var summaries = BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args); | ||
} | ||
} | ||
} | ||
} |
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,3 @@ | ||
@pushd "%~dp0\" | ||
dotnet run -f netcoreapp2.2 -c release -- --runtimes net472 netcoreapp2.2 %* | ||
@popd |
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
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
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
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
Oops, something went wrong.