Add SendAsyncGroup to broadcast benchmarks (#1852)

This commit is contained in:
James Newton-King 2018-04-05 14:58:00 +12:00 committed by GitHub
parent 32b4d5cc6c
commit 6b76d1355e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 0 deletions

View File

@ -14,6 +14,7 @@ namespace Microsoft.AspNetCore.SignalR.Microbenchmarks
{
public class BroadcastBenchmark
{
private const string TestGroupName = "TestGroup";
private DefaultHubLifetimeManager<Hub> _hubLifetimeManager;
private HubContext<Hub> _hubContext;
@ -47,6 +48,7 @@ namespace Microsoft.AspNetCore.SignalR.Microbenchmarks
var hubConnection = new HubConnectionContext(connection, Timeout.InfiniteTimeSpan, NullLoggerFactory.Instance);
hubConnection.Protocol = protocol;
_hubLifetimeManager.OnConnectedAsync(hubConnection).GetAwaiter().GetResult();
_hubLifetimeManager.AddGroupAsync(connection.ConnectionId, TestGroupName).GetAwaiter().GetResult();
_ = ConsumeAsync(connection.Application);
}
@ -54,6 +56,12 @@ namespace Microsoft.AspNetCore.SignalR.Microbenchmarks
_hubContext = new HubContext<Hub>(_hubLifetimeManager);
}
[Benchmark]
public Task SendAsyncGroup()
{
return _hubContext.Clients.Group(TestGroupName).SendAsync("Method");
}
[Benchmark]
public Task SendAsyncAll()
{