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
15 changes: 9 additions & 6 deletions frameworks/CSharp/genhttp/Benchmarks/Benchmarks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@

<PropertyGroup>

<TargetFramework>net9.0</TargetFramework>
<LangVersion>13.0</LangVersion>
<TargetFramework>net10.0</TargetFramework>
<LangVersion>14.0</LangVersion>
<ImplicitUsings>true</ImplicitUsings>
<OutputType>Exe</OutputType>

<AssemblyTitle>GenHTTP Benchmarks</AssemblyTitle>
<Description>Test suite to be executed with TechEmpower FrameworkBenchmarks.</Description>

<DefineConstants>$(DefineConstants);$(GENHTTP_ENGINE_NAME)</DefineConstants>

<ServerGarbageCollection>true</ServerGarbageCollection>
<TieredPGO>true</TieredPGO>

Expand All @@ -26,11 +28,12 @@

<ItemGroup>

<PackageReference Include="GenHTTP.Core" Version="9.8.0" />
<PackageReference Include="GenHTTP.Modules.Webservices" Version="9.8.0" />
<PackageReference Include="$(GENHTTP_ENGINE_PACKAGE)" Version="10.0.0" />

<PackageReference Include="GenHTTP.Modules.Webservices" Version="10.0.0" />

<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.10" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="10.0.0" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="10.0.0-rc.2" />

</ItemGroup>

Expand Down
4 changes: 4 additions & 0 deletions frameworks/CSharp/genhttp/Benchmarks/Program.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
using Benchmarks.Tests;
using Benchmarks.Utilities;

#if INTERNAL
using GenHTTP.Engine.Internal;
#else
using GenHTTP.Engine.Kestrel;
#endif

using GenHTTP.Modules.IO;
using GenHTTP.Modules.Layouting;
Expand Down
12 changes: 4 additions & 8 deletions frameworks/CSharp/genhttp/Benchmarks/Tests/JsonHandler.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
using System.Text.Json;
using Benchmarks.Utilities;

using GenHTTP.Api.Content;
using GenHTTP.Api.Protocol;

using GenHTTP.Modules.Conversion.Serializers.Json;

namespace Benchmarks.Tests;

public sealed class JsonResult
Expand All @@ -15,9 +13,7 @@ public sealed class JsonResult

public sealed class JsonHandler : IHandler
{
private static readonly FlexibleContentType _ContentType = new(ContentType.ApplicationJson, "utf-8");

private static readonly JsonSerializerOptions _Options = new();
private static readonly FlexibleContentType ContentType = new(GenHTTP.Api.Protocol.ContentType.ApplicationJson, "utf-8");

public ValueTask PrepareAsync() => new();

Expand All @@ -29,8 +25,8 @@ public ValueTask<IResponse> HandleAsync(IRequest request)
};

var response = request.Respond()
.Content(new JsonContent(result, _Options))
.Type(_ContentType)
.Content(new FixedLengthJsonContent(result))
.Type(ContentType)
.Build();

return new(response);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System.Text.Json;

using GenHTTP.Api.Protocol;

using Benchmarks.Tests;

namespace Benchmarks.Utilities;

public sealed class FixedLengthJsonContent : IResponseContent
{
private readonly MemoryStream _buffer = new();

public ulong? Length => (ulong)_buffer.Length;

public FixedLengthJsonContent(JsonResult result)
{
JsonSerializer.SerializeAsync(_buffer, result);
}

public ValueTask<ulong?> CalculateChecksumAsync() => throw new NotImplementedException();

public ValueTask WriteAsync(Stream target, uint bufferSize)
{
_buffer.Seek(0, SeekOrigin.Begin);

_buffer.CopyTo(target);

return ValueTask.CompletedTask;
}

}
33 changes: 29 additions & 4 deletions frameworks/CSharp/genhttp/benchmark_config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"framework": "genhttp",
"framework": "genhttp",
"maintainers": ["Kaliumhexacyanoferrat"],
"tests": [{
"default": {
"plaintext_url": "/plaintext",
Expand All @@ -17,11 +18,35 @@
"language": "C#",
"orm": "Raw",
"platform": ".NET",
"webserver": "Kestrel",
"webserver": "GenHTTP",
"os": "Linux",
"database_os": "Linux",
"display_name": "GenHTTP",
"display_name": "genhttp [internal]",
"notes": ""
}
}]
},
{
"kestrel": {
"plaintext_url": "/plaintext",
"json_url": "/json",
"db_url": "/db",
"query_url": "/queries/",
"update_url": "/updates/",
"fortune_url": "/fortunes",
"cached_query_url": "/cached-worlds/",
"port": 8080,
"approach": "Realistic",
"classification": "Fullstack",
"database": "Postgres",
"framework": "GenHTTP",
"language": "C#",
"orm": "Raw",
"platform": ".NET",
"webserver": "Kestrel",
"os": "Linux",
"database_os": "Linux",
"display_name": "genhttp [kestrel]",
"notes": ""
}
}]
}
18 changes: 18 additions & 0 deletions frameworks/CSharp/genhttp/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,23 @@ database_os = "Linux"
os = "Linux"
orm = "Raw"
platform = ".NET"
webserver = "GenHTTP"
versus = "None"

[kestrel]
urls.plaintext = "/plaintext"
urls.json = "/json"
urls.db = "/db"
urls.query = "/queries/"
urls.update = "/updates/"
urls.fortune = "/fortunes"
urls.cached_query = "/cached-worlds/"
approach = "Realistic"
classification = "Fullstack"
database = "Postgres"
database_os = "Linux"
os = "Linux"
orm = "Raw"
platform = ".NET"
webserver = "Kestrel"
versus = "None"
33 changes: 33 additions & 0 deletions frameworks/CSharp/genhttp/genhttp-kestrel.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
FROM mcr.microsoft.com/dotnet/sdk:10.0-alpine AS build
WORKDIR /source

ENV GENHTTP_ENGINE_NAME=KESTREL
ENV GENHTTP_ENGINE_PACKAGE=GenHTTP.Core.Kestrel

# copy csproj and restore as distinct layers
COPY Benchmarks/*.csproj .
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 --no-restore --self-contained

# final stage/image
FROM mcr.microsoft.com/dotnet/runtime-deps:10.0-alpine

ENV DOTNET_GCDynamicAdaptationMode=0 \
DOTNET_EnableDiagnostics=0 \
COMPlus_EnableDiagnostics=0 \
COMPlus_DbgEnableMiniDump=0 \
COMPlus_DbgEnableMiniDumpCollection=0 \
COMPlus_DbgMiniDumpType=0 \
DOTNET_TieredPGO=0 \
DOTNET_TC_QuickJitForLoops=1 \
DOTNET_TC_QuickJit=1

WORKDIR /app
COPY --from=build /app .

ENTRYPOINT ["./Benchmarks"]

EXPOSE 8080
19 changes: 14 additions & 5 deletions frameworks/CSharp/genhttp/genhttp.dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
FROM mcr.microsoft.com/dotnet/sdk:9.0-alpine AS build
FROM mcr.microsoft.com/dotnet/sdk:10.0-alpine AS build
WORKDIR /source

ENV GENHTTP_ENGINE_NAME=INTERNAL
ENV GENHTTP_ENGINE_PACKAGE=GenHTTP.Core

# copy csproj and restore as distinct layers
COPY Benchmarks/*.csproj .
RUN dotnet restore -r linux-musl-x64
Expand All @@ -10,11 +13,17 @@ COPY Benchmarks/ .
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:9.0-alpine
FROM mcr.microsoft.com/dotnet/runtime-deps:10.0-alpine

ENV DOTNET_GCDynamicAdaptationMode=0
ENV DOTNET_ReadyToRun=0
ENV DOTNET_HillClimbing_Disable=1
ENV DOTNET_GCDynamicAdaptationMode=0 \
DOTNET_EnableDiagnostics=0 \
COMPlus_EnableDiagnostics=0 \
COMPlus_DbgEnableMiniDump=0 \
COMPlus_DbgEnableMiniDumpCollection=0 \
COMPlus_DbgMiniDumpType=0 \
DOTNET_TieredPGO=0 \
DOTNET_TC_QuickJitForLoops=1 \
DOTNET_TC_QuickJit=1

WORKDIR /app
COPY --from=build /app .
Expand Down
Loading