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
30 changes: 30 additions & 0 deletions benchmarks.sln
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "H2LoadClient", "src\H2LoadC
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MapAction", "src\BenchmarksApps\MapAction\MapAction.csproj", "{BC85E290-2C5E-4231-80DC-FEAB371A7417}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BenchmarkServer", "src\BenchmarksApps\Websocket\BenchmarkServer.csproj", "{0F1BF7D3-0525-42E6-8AEB-58E44D122ADA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebsocketClient", "src\WebsocketClient\WebsocketClient.csproj", "{28BE6B12-0515-44D9-B3E5-2B9D016BF5B1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -658,6 +662,30 @@ Global
{BC85E290-2C5E-4231-80DC-FEAB371A7417}.Release|x64.Build.0 = Release|Any CPU
{BC85E290-2C5E-4231-80DC-FEAB371A7417}.Release|x86.ActiveCfg = Release|Any CPU
{BC85E290-2C5E-4231-80DC-FEAB371A7417}.Release|x86.Build.0 = Release|Any CPU
{0F1BF7D3-0525-42E6-8AEB-58E44D122ADA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0F1BF7D3-0525-42E6-8AEB-58E44D122ADA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0F1BF7D3-0525-42E6-8AEB-58E44D122ADA}.Debug|x64.ActiveCfg = Debug|Any CPU
{0F1BF7D3-0525-42E6-8AEB-58E44D122ADA}.Debug|x64.Build.0 = Debug|Any CPU
{0F1BF7D3-0525-42E6-8AEB-58E44D122ADA}.Debug|x86.ActiveCfg = Debug|Any CPU
{0F1BF7D3-0525-42E6-8AEB-58E44D122ADA}.Debug|x86.Build.0 = Debug|Any CPU
{0F1BF7D3-0525-42E6-8AEB-58E44D122ADA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0F1BF7D3-0525-42E6-8AEB-58E44D122ADA}.Release|Any CPU.Build.0 = Release|Any CPU
{0F1BF7D3-0525-42E6-8AEB-58E44D122ADA}.Release|x64.ActiveCfg = Release|Any CPU
{0F1BF7D3-0525-42E6-8AEB-58E44D122ADA}.Release|x64.Build.0 = Release|Any CPU
{0F1BF7D3-0525-42E6-8AEB-58E44D122ADA}.Release|x86.ActiveCfg = Release|Any CPU
{0F1BF7D3-0525-42E6-8AEB-58E44D122ADA}.Release|x86.Build.0 = Release|Any CPU
{28BE6B12-0515-44D9-B3E5-2B9D016BF5B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{28BE6B12-0515-44D9-B3E5-2B9D016BF5B1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{28BE6B12-0515-44D9-B3E5-2B9D016BF5B1}.Debug|x64.ActiveCfg = Debug|Any CPU
{28BE6B12-0515-44D9-B3E5-2B9D016BF5B1}.Debug|x64.Build.0 = Debug|Any CPU
{28BE6B12-0515-44D9-B3E5-2B9D016BF5B1}.Debug|x86.ActiveCfg = Debug|Any CPU
{28BE6B12-0515-44D9-B3E5-2B9D016BF5B1}.Debug|x86.Build.0 = Debug|Any CPU
{28BE6B12-0515-44D9-B3E5-2B9D016BF5B1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{28BE6B12-0515-44D9-B3E5-2B9D016BF5B1}.Release|Any CPU.Build.0 = Release|Any CPU
{28BE6B12-0515-44D9-B3E5-2B9D016BF5B1}.Release|x64.ActiveCfg = Release|Any CPU
{28BE6B12-0515-44D9-B3E5-2B9D016BF5B1}.Release|x64.Build.0 = Release|Any CPU
{28BE6B12-0515-44D9-B3E5-2B9D016BF5B1}.Release|x86.ActiveCfg = Release|Any CPU
{28BE6B12-0515-44D9-B3E5-2B9D016BF5B1}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -717,6 +745,8 @@ Global
{E82AA66D-270B-4041-9D8B-364E54D4E962} = {A9BDD13F-8E19-459E-BE3F-4484AE699265}
{7AFACAC0-EFD1-4736-B512-06E8282BB222} = {39985004-8041-41FC-BBB1-CCF999D7BC16}
{BC85E290-2C5E-4231-80DC-FEAB371A7417} = {A9BDD13F-8E19-459E-BE3F-4484AE699265}
{0F1BF7D3-0525-42E6-8AEB-58E44D122ADA} = {A9BDD13F-8E19-459E-BE3F-4484AE699265}
{28BE6B12-0515-44D9-B3E5-2B9D016BF5B1} = {995FCFF9-E5F6-4BDD-8E5B-FBDEA21145F9}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C48AD7EE-82B1-4307-A869-3FC14AC9B21F}
Expand Down
42 changes: 40 additions & 2 deletions build/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -366,11 +366,49 @@ jobs:
duration: 15
connection: ASP.NET Benchmarks Mono Queue

- job: Websocket_Linux
displayName: Websocket
pool: server
timeoutInMinutes: 120
dependsOn: SignalR_Linux
condition: and(succeededOrFailed(), eq(variables['pm'], true))
strategy:
maxParallel: 1
matrix:
Intel_Linux:
profile: aspnet-citrine-lin
steps:
- template: websocket-scenarios.yml
parameters:
profile: $(profile)
warmup: 1
duration: 15
connection: ASP.NET Benchmarks Queue

- job: Websocket_Windows
displayName: Websocket
pool: server
timeoutInMinutes: 120
dependsOn: SignalR_Windows
condition: and(succeededOrFailed(), eq(variables['pm'], true))
strategy:
maxParallel: 1
matrix:
Intel_Windows:
profile: aspnet-citrine-win
steps:
- template: websocket-scenarios.yml
parameters:
profile: $(profile)
warmup: 1
duration: 15
connection: ASP.NET Benchmarks Mono Queue

- job: SingleFile_Linux
displayName: Single File
pool: server
timeoutInMinutes: 120
dependsOn: SignalR_Linux
dependsOn: Websocket_Linux
condition: and(succeededOrFailed(), eq(variables['pm'], true))
strategy:
maxParallel: 1
Expand All @@ -389,7 +427,7 @@ jobs:
displayName: Single File
pool: server
timeoutInMinutes: 120
dependsOn: SignalR_Windows
dependsOn: Websocket_Windows
condition: and(succeededOrFailed(), eq(variables['pm'], true))
strategy:
maxParallel: 1
Expand Down
3 changes: 3 additions & 0 deletions build/job-variables.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ variables:
- name: signalRJobs
value: --config https://raw.githubusercontent.com/aspnet/Benchmarks/main/scenarios/signalr.benchmarks.yml

- name: websocketJobs
value: --config https://raw.githubusercontent.com/aspnet/Benchmarks/main/scenarios/websocket.benchmarks.yml

- name: proxyJobs
value: --config https://raw.githubusercontent.com/aspnet/Benchmarks/main/scenarios/proxy.benchmarks.yml
- name: proxyGRPCJobs
Expand Down
39 changes: 39 additions & 0 deletions build/websocket-scenarios.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Websocket scenarios

parameters:
- name: profile
type: string
default: ''
- name: warmup
type: number
default: 0
- name: duration
type: number
default: 15
- name: connection
type: string
default: ''

# Scenarios
- name: scenarios
type: object
default:

- displayName: Echo
arguments: --scenario websocket $(websocketJobs) --variable scenario=echo --property scenario=echo

steps:
- ${{ each s in parameters.scenarios }}:
- task: PublishToAzureServiceBus@1
condition: succeededOrFailed()
displayName: ${{ s.displayName }}
inputs:
connectedServiceName: ${{ parameters.connection }}
waitForCompletion: true
messageBody: |
{
"timeout": "00:5:00",
"name": "crank",
"args": [ "${{ s.arguments }} --application.options.collectCounters true --load.options.collectCounters true --load.variables.warmup ${{ parameters.warmup }} --load.variables.duration ${{ parameters.duration }} --profile ${{ parameters.profile }} --load.channel edge --load.framework net6.0 --application.channel edge --application.framework net6.0 --session $(session) --table WebsocketBenchmarks --sql SQL_CONNECTION_STRING --chart --no-measurements --no-metadata --warmup.options.discardResults true" ]
}

19 changes: 19 additions & 0 deletions scenarios/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,25 @@ crank --config https://raw.githubusercontent.com/aspnet/Benchmarks/main/scenario

> Note: MessagePack is not supported with ServerSentEvents

## Websockets benchmarks

These scenarios are running various Websockets benchmarks.

### Sample

```
crank --config https://raw.githubusercontent.com/aspnet/Benchmarks/main/scenarios/websocket.benchmarks.yml --scenario websocket --profile aspnet-perf-lin --variable scenario=echo
```

### Available scenarios

- `websocket`

#### Arguments

- Scenario:
- `--variable scenario=echo`

## Orchard benchmarks

These scenarios are running various Orchard Core CMS benchmarks with either Sqlite or PostgresQL.
Expand Down
21 changes: 21 additions & 0 deletions scenarios/websocket.benchmarks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Examples:
# --config benchmarks.websocket.yml --scenario websocket --variable scenario=echo --profile asp-perf-lin

imports:
- https://raw.githubusercontent.com/aspnet/Benchmarks/main/src/WebsocketClient/websocketclient.yml
- https://raw.githubusercontent.com/aspnet/Benchmarks/main/src/BenchmarksApps/Websocket/websocketServer.yml
- https://github.com/aspnet/Benchmarks/blob/main/scenarios/aspnet.profiles.yml?raw=true

variables:
serverPort: 5000
serverScheme: ws

scenarios:
websocket:
application:
job: websocketServer
load:
job: websocketClient
variables:
path: /Echo
warmup: 5
23 changes: 23 additions & 0 deletions src/BenchmarksApps/Websocket/BenchmarkServer.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<None Remove="websocketServer.yml" />
</ItemGroup>

<ItemGroup>
<Content Include="websocketserver.yml" />
</ItemGroup>

<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Crank.EventSources" Version="0.1.0-alpha.20501.1" />
</ItemGroup>

</Project>
39 changes: 39 additions & 0 deletions src/BenchmarksApps/Websocket/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.Diagnostics;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;

namespace BenchmarkServer
{
public class Program
{
public static void Main(string[] args)
{
Console.WriteLine($"Process ID: {Process.GetCurrentProcess().Id}");

var config = new ConfigurationBuilder()
.AddEnvironmentVariables(prefix: "ASPNETCORE_")
.AddCommandLine(args)
.Build();

var host = new WebHostBuilder()
.UseConfiguration(config)
.ConfigureLogging(loggerFactory =>
{
if (Enum.TryParse(config["LogLevel"], out LogLevel logLevel))
{
loggerFactory.AddConsole().SetMinimumLevel(logLevel);
}
})
.UseKestrel()
.UseStartup<Startup>();

host.Build().Run();
}
}
}
17 changes: 17 additions & 0 deletions src/BenchmarksApps/Websocket/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## Purpose

This project is to assist in Benchmarking Websockets.
It makes it easier to test local changes than having the App in the Benchmarks repo by letting us make changes in websocket branches and using the example commandline below to run the benchmarks against our branches.

The WebsocketWorker that runs against this server is located at https://github.com/aspnet/benchmarks/blob/main/src/WebsocketClient/Program.cs.

## Usage

1. Push changes you would like to test to a branch on GitHub
2. Clone aspnet/benchmarks repo to your machine or install the global BenchmarksDriver tool https://www.nuget.org/packages/BenchmarksDriver/
3. If cloned go to the BenchmarksDriver project
4. Use the following command as a guideline for running a test using your changes

`benchmarks --config benchmarks.websocket.yml --scenario echo --variable serverUri=http://10.0.0.102 --load.endpoints http://10.0.0.102:5001

5. For more info/commands see https://github.com/aspnet/benchmarks/blob/main/src/BenchmarksDriver2/README.md
64 changes: 64 additions & 0 deletions src/BenchmarksApps/Websocket/Startup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.Net;
using System.Net.WebSockets;
using System.Threading;
using System.Threading.Tasks;
using System.Web;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;

namespace BenchmarkServer
{
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddRouting();
}

public void Configure(IApplicationBuilder app)
{
app.UseRouting();
app.UseWebSockets();
app.Use(async (context, next) =>
{
if (context.Request.Path == "/Echo")
{
if (context.WebSockets.IsWebSocketRequest)
{
using (WebSocket webSocket = await context.WebSockets.AcceptWebSocketAsync())
{
await Echo(webSocket);
}
}
else
{
context.Response.StatusCode = (int)HttpStatusCode.BadRequest;
}
}
else
{
await next();
}
});
}

private async Task Echo(WebSocket webSocket)
{
var buffer = new byte[1024 * 4];
var result = await webSocket.ReceiveAsync(new ArraySegment<byte>(buffer), CancellationToken.None);
while (!result.CloseStatus.HasValue)
{
await webSocket.SendAsync(new ArraySegment<byte>(buffer, 0, result.Count), result.MessageType, result.EndOfMessage, CancellationToken.None);
result = await webSocket.ReceiveAsync(new ArraySegment<byte>(buffer), CancellationToken.None);
}
await webSocket.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None);
}
}
}
10 changes: 10 additions & 0 deletions src/BenchmarksApps/Websocket/websocketServer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

jobs:
websocketServer:
source:
repository: https://github.com/aspnet/benchmarks.git
branchOrCommit: main
project: src/BenchmarksApps/Websocket/BenchmarkServer.csproj
readyStateText: Application started
runtimeVersion: '6.0.*'
waitForExit: false
2 changes: 1 addition & 1 deletion src/TcpClient/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ static async Task Main(string[] args)
return Task.CompletedTask;
});

await app.ExecuteAsync(args);
await app.ExecuteAsync(args);
}

private static async Task ScheduleAsync()
Expand Down
Loading