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
8 changes: 4 additions & 4 deletions frameworks/CSharp/watson/Benchmarks/Benchmarks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

<PropertyGroup>

<TargetFramework>net5.0</TargetFramework>
<LangVersion>9.0</LangVersion>
<TargetFramework>net9.0</TargetFramework>
<LangVersion>13.0</LangVersion>

<AssemblyTitle>EmbedIO Benchmarks</AssemblyTitle>
<Description>Test suite to be executed with TechEmpower FrameworkBenchmarks.</Description>
Expand All @@ -17,8 +17,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.Text.Json" Version="5.0.0" />
<PackageReference Include="Watson" Version="4.0.0.3" />
<PackageReference Include="System.Text.Json" Version="9.0.10" />
<PackageReference Include="Watson" Version="6.4.0" />
</ItemGroup>

</Project>
24 changes: 12 additions & 12 deletions frameworks/CSharp/watson/Benchmarks/Program.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
using System;
using System.Linq;
using System.Net;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;

using WatsonWebserver;
using WatsonWebserver.Core;

namespace Benchmarks
{
Expand All @@ -23,7 +22,7 @@ public class JsonResult

public static class Program
{
private static readonly ManualResetEvent _WaitEvent = new ManualResetEvent(false);
private static readonly ManualResetEvent WaitEvent = new(false);

public static async Task<int> Main(string[] args)
{
Expand All @@ -33,21 +32,23 @@ public static async Task<int> Main(string[] args)
var host = "tfb-server";
#endif

using var server = new Server(host, 8080, false, DefaultRoute);
var settings = new WebserverSettings(host, 8080, false);

server.Routes.Static.Add(HttpMethod.GET, "/plaintext", PlaintextRoute);
server.Routes.Static.Add(HttpMethod.GET, "/json", JsonRoute);
using var server = new Webserver(settings, DefaultRoute);

server.Routes.PreAuthentication.Static.Add(HttpMethod.GET, "/plaintext", PlaintextRoute);
server.Routes.PreAuthentication.Static.Add(HttpMethod.GET, "/json", JsonRoute);

try
{
AppDomain.CurrentDomain.ProcessExit += (_, __) =>
{
_WaitEvent.Set();
WaitEvent.Set();
};

await server.StartAsync();

_WaitEvent.WaitOne();
WaitEvent.WaitOne();

return 0;
}
Expand All @@ -59,22 +60,21 @@ public static async Task<int> Main(string[] args)
}
}

static async Task DefaultRoute(HttpContext ctx)
static async Task DefaultRoute(HttpContextBase ctx)
{
ctx.Response.StatusCode = 404;
ctx.Response.StatusDescription = "Not Found";

await ctx.Response.Send("Not found.");
}

static async Task PlaintextRoute(HttpContext ctx)
static async Task PlaintextRoute(HttpContextBase ctx)
{
ctx.Response.Headers.Add("Content-Type", "text/plain; charset=UTF-8");

await ctx.Response.Send("Hello, World!");
}

static async Task JsonRoute(HttpContext ctx)
static async Task JsonRoute(HttpContextBase ctx)
{
var response = new JsonResult() { Message = "Hello, World!" };
var serialized = JsonSerializer.Serialize(response);
Expand Down
4 changes: 2 additions & 2 deletions frameworks/CSharp/watson/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ See the [project website](https://github.com/jchristn/WatsonWebserver) for more

**Language**

* C# 9.0
* C# 13.0

**Platforms**

* .NET 5
* .NET 9

**Web Servers**

Expand Down
3 changes: 1 addition & 2 deletions frameworks/CSharp/watson/benchmark_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
"os": "Linux",
"database_os": "Linux",
"display_name": "Watson Webserver",
"notes": "",
"tags": ["broken"]
"notes": ""
}
}]
}
6 changes: 3 additions & 3 deletions frameworks/CSharp/watson/watson.dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/sdk:5.0-alpine AS build
FROM mcr.microsoft.com/dotnet/sdk:9.0-alpine AS build
WORKDIR /source

# copy csproj and restore as distinct layers
Expand All @@ -7,10 +7,10 @@ RUN dotnet restore -r linux-musl-x64

# copy and publish app and libraries
COPY Benchmarks/ .
RUN dotnet publish -c release -o /app -r linux-musl-x64
RUN dotnet publish -c release -o /app -r linux-musl-x64 --no-restore --self-contained

# final stage/image
FROM mcr.microsoft.com/dotnet/runtime-deps:5.0-alpine
FROM mcr.microsoft.com/dotnet/runtime-deps:9.0-alpine
WORKDIR /app
COPY --from=build /app .

Expand Down
Loading