Skip to content
This repository was archived by the owner on Mar 24, 2026. It is now read-only.
Closed
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
9 changes: 5 additions & 4 deletions frameworks/CSharp/aspnetcore/Benchmarks/Benchmarks.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<OutputType>Exe</OutputType>
<ImplicitUsings>enable</ImplicitUsings>
<TieredPGO>true</TieredPGO>
</PropertyGroup>

<ItemGroup>
Expand All @@ -13,10 +14,10 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.0" />

<PackageReference Include="Dapper" Version="2.0.123" />
<PackageReference Include="MySqlConnector" Version="2.0.0" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="6.0.0" />
<PackageReference Include="MySqlConnector" Version="2.2.0" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.0" />
</ItemGroup>
</Project>
57 changes: 0 additions & 57 deletions frameworks/CSharp/aspnetcore/PlatformBenchmarks/AsciiString.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ namespace PlatformBenchmarks
{
public partial class BenchmarkApplication
{
private readonly static AsciiString _fortunesPreamble =
_http11OK +
_headerServer + _crlf +
_headerContentTypeHtml + _crlf +
_headerContentLength;
private static ReadOnlySpan<byte> _fortunesPreamble =>
"HTTP/1.1 200 OK\r\n"u8 +
"Server: K"u8 + "\r\n"u8 +
"Content-Type: text/html; charset=UTF-8"u8 + "\r\n"u8 +
"Content-Length: "u8;

private async Task Fortunes(PipeWriter pipeWriter)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ public partial class BenchmarkApplication
{
private readonly static uint _jsonPayloadSize = (uint)JsonSerializer.SerializeToUtf8Bytes(new JsonMessage { message = "Hello, World!" }, SerializerContext.JsonMessage).Length;

private readonly static AsciiString _jsonPreamble =
_http11OK +
_headerServer + _crlf +
_headerContentTypeJson + _crlf +
_headerContentLength + _jsonPayloadSize.ToString();
private static ReadOnlySpan<byte> _jsonPreamble =>
"HTTP/1.1 200 OK\r\n"u8 +
"Server: K"u8 + "\r\n"u8 +
"Content-Type: application/json"u8 + "\r\n"u8 +
"Content-Length: 27"u8;

private static void Json(ref BufferWriter<WriterAdapter> writer, IBufferWriter<byte> bodyWriter)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ namespace PlatformBenchmarks;

public partial class BenchmarkApplication
{
private readonly static AsciiString _plaintextPreamble =
_http11OK +
_headerServer + _crlf +
_headerContentTypeText + _crlf +
_headerContentLength + _plainTextBody.Length.ToString();
private static ReadOnlySpan<byte> _plaintextPreamble =>
"HTTP/1.1 200 OK\r\n"u8 +
"Server: K\r\n"u8 +
"Content-Type: text/plain\r\n"u8 +
"Content-Length: 13"u8;

private static void PlainText(ref BufferWriter<WriterAdapter> writer)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,27 @@ namespace PlatformBenchmarks;

public partial class BenchmarkApplication
{
private readonly static AsciiString _applicationName = "Kestrel Platform-Level Application";
public static AsciiString ApplicationName => _applicationName;

private readonly static AsciiString _crlf = "\r\n";
private readonly static AsciiString _eoh = "\r\n\r\n"; // End Of Headers
private readonly static AsciiString _http11OK = "HTTP/1.1 200 OK\r\n";
private readonly static AsciiString _http11NotFound = "HTTP/1.1 404 Not Found\r\n";
private readonly static AsciiString _headerServer = "Server: K";
private readonly static AsciiString _headerContentLength = "Content-Length: ";
private readonly static AsciiString _headerContentLengthZero = "Content-Length: 0";
private readonly static AsciiString _headerContentTypeText = "Content-Type: text/plain";
private readonly static AsciiString _headerContentTypeJson = "Content-Type: application/json";
private readonly static AsciiString _headerContentTypeHtml = "Content-Type: text/html; charset=UTF-8";

private readonly static AsciiString _dbPreamble =
_http11OK +
_headerServer + _crlf +
_headerContentTypeJson + _crlf +
_headerContentLength;

private readonly static AsciiString _plainTextBody = "Hello, World!";
private static ReadOnlySpan<byte> _applicationName => "Kestrel Platform-Level Application"u8;
public static ReadOnlySpan<byte> ApplicationName => _applicationName;

private static ReadOnlySpan<byte> _crlf => "\r\n"u8;
private static ReadOnlySpan<byte> _eoh => "\r\n\r\n"u8; // End Of Headers
private static ReadOnlySpan<byte> _http11OK => "HTTP/1.1 200 OK\r\n"u8;
private static ReadOnlySpan<byte> _http11NotFound => "HTTP/1.1 404 Not Found\r\n"u8;
private static ReadOnlySpan<byte> _headerServer => "Server: K"u8;
private static ReadOnlySpan<byte> _headerContentLength => "Content-Length: "u8;
private static ReadOnlySpan<byte> _headerContentLengthZero => "Content-Length: 0"u8;
private static ReadOnlySpan<byte> _headerContentTypeText => "Content-Type: text/plain"u8;
private static ReadOnlySpan<byte> _headerContentTypeJson => "Content-Type: application/json"u8;
private static ReadOnlySpan<byte> _headerContentTypeHtml => "Content-Type: text/html; charset=UTF-8"u8;

private static ReadOnlySpan<byte> _dbPreamble =>
"HTTP/1.1 200 OK\r\n"u8 +
"Server: K\r\n"u8 +
"Content-Type: application/json\r\n"u8 +
"Content-Length: "u8;

private static ReadOnlySpan<byte> _plainTextBody => "Hello, World!"u8;

private static readonly JsonContext SerializerContext = JsonContext.Default;

Expand All @@ -46,12 +46,12 @@ private sealed partial class JsonContext : JsonSerializerContext
{
}

private readonly static AsciiString _fortunesTableStart = "<!DOCTYPE html><html><head><title>Fortunes</title></head><body><table><tr><th>id</th><th>message</th></tr>";
private readonly static AsciiString _fortunesRowStart = "<tr><td>";
private readonly static AsciiString _fortunesColumn = "</td><td>";
private readonly static AsciiString _fortunesRowEnd = "</td></tr>";
private readonly static AsciiString _fortunesTableEnd = "</table></body></html>";
private readonly static AsciiString _contentLengthGap = new string(' ', 4);
private static ReadOnlySpan<byte> _fortunesTableStart => "<!DOCTYPE html><html><head><title>Fortunes</title></head><body><table><tr><th>id</th><th>message</th></tr>"u8;
private static ReadOnlySpan<byte> _fortunesRowStart => "<tr><td>"u8;
private static ReadOnlySpan<byte> _fortunesColumn => "</td><td>"u8;
private static ReadOnlySpan<byte> _fortunesRowEnd => "</td></tr>"u8;
private static ReadOnlySpan<byte> _fortunesTableEnd => "</table></body></html>"u8;
private static ReadOnlySpan<byte> _contentLengthGap => " "u8;

#if DATABASE
public static RawDb Db { get; set; }
Expand All @@ -62,13 +62,13 @@ private sealed partial class JsonContext : JsonSerializerContext

public static class Paths
{
public readonly static AsciiString Json = "/json";
public readonly static AsciiString Plaintext = "/plaintext";
public readonly static AsciiString SingleQuery = "/db";
public readonly static AsciiString Fortunes = "/fortunes";
public readonly static AsciiString Updates = "/updates/";
public readonly static AsciiString MultipleQueries = "/queries/";
public readonly static AsciiString Caching = "/cached-worlds/";
public static ReadOnlySpan<byte> Json => "/json"u8;
public static ReadOnlySpan<byte> Plaintext => "/plaintext"u8;
public static ReadOnlySpan<byte> SingleQuery => "/db"u8;
public static ReadOnlySpan<byte> Fortunes => "/fortunes"u8;
public static ReadOnlySpan<byte> Updates => "/updates/"u8;
public static ReadOnlySpan<byte> MultipleQueries => "/queries/"u8;
public static ReadOnlySpan<byte> Caching => "/cached-worlds/"u8;
}

private RequestType _requestType;
Expand Down Expand Up @@ -169,11 +169,11 @@ private static Task Default(PipeWriter pipeWriter)
return Task.CompletedTask;
}
#endif
private readonly static AsciiString _defaultPreamble =
_http11NotFound +
_headerServer + _crlf +
_headerContentTypeText + _crlf +
_headerContentLengthZero;
private static ReadOnlySpan<byte> _defaultPreamble =>
"HTTP/1.1 200 OK\r\n"u8 +
"Server: K"u8 + "\r\n"u8 +
"Content-Type: text/plain"u8 +
"Content-Length: 0"u8;

private static void Default(ref BufferWriter<WriterAdapter> writer)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ public sealed class CachedWorld

public int RandomNumber { get; set; }

public static implicit operator CachedWorld(World world) => new CachedWorld { Id = world.Id, RandomNumber = world.RandomNumber };
public static implicit operator CachedWorld(World world) => new() { Id = world.Id, RandomNumber = world.RandomNumber };
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ private static void SetDateValues(DateTimeOffset value)
throw new Exception("date time format failed");
}
Debug.Assert(written == dateTimeRLength);
var temp = s_headerBytesMaster;
s_headerBytesMaster = s_headerBytesScratch;
s_headerBytesScratch = temp;
(s_headerBytesScratch, s_headerBytesMaster) = (s_headerBytesMaster, s_headerBytesScratch);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<OutputType>Exe</OutputType>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<ImplicitUsings>enable</ImplicitUsings>
<TieredPGO>true</TieredPGO>
</PropertyGroup>

<PropertyGroup>
Expand Down
15 changes: 8 additions & 7 deletions frameworks/CSharp/aspnetcore/PlatformBenchmarks/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System.Runtime.InteropServices;
using System.Text;

namespace PlatformBenchmarks;

Expand All @@ -13,15 +14,15 @@ public static async Task Main(string[] args)
{
Args = args;

Console.WriteLine(BenchmarkApplication.ApplicationName);
Console.WriteLine(Encoding.UTF8.GetString(BenchmarkApplication.ApplicationName));
#if !DATABASE
Console.WriteLine(BenchmarkApplication.Paths.Plaintext);
Console.WriteLine(BenchmarkApplication.Paths.Json);
Console.WriteLine(Encoding.UTF8.GetString(BenchmarkApplication.Paths.Plaintext));
Console.WriteLine(Encoding.UTF8.GetString(BenchmarkApplication.Paths.Json));
#else
Console.WriteLine(BenchmarkApplication.Paths.Fortunes);
Console.WriteLine(BenchmarkApplication.Paths.SingleQuery);
Console.WriteLine(BenchmarkApplication.Paths.Updates);
Console.WriteLine(BenchmarkApplication.Paths.MultipleQueries);
Console.WriteLine(Encoding.UTF8.GetString(BenchmarkApplication.Paths.Fortunes));
Console.WriteLine(Encoding.UTF8.GetString(BenchmarkApplication.Paths.SingleQuery));
Console.WriteLine(Encoding.UTF8.GetString(BenchmarkApplication.Paths.Updates));
Console.WriteLine(Encoding.UTF8.GetString(BenchmarkApplication.Paths.MultipleQueries));
#endif
DateHeader.SyncDateTimer();

Expand Down
4 changes: 2 additions & 2 deletions frameworks/CSharp/aspnetcore/aspcore-ado-my.dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM mcr.microsoft.com/dotnet/sdk:6.0.100 AS build
FROM mcr.microsoft.com/dotnet/sdk:7.0.100 AS build
WORKDIR /app
COPY PlatformBenchmarks .
RUN dotnet publish -c Release -o out /p:DatabaseProvider=MySqlConnector

FROM mcr.microsoft.com/dotnet/aspnet:6.0.0 AS runtime
FROM mcr.microsoft.com/dotnet/aspnet:7.0.0 AS runtime
ENV ASPNETCORE_URLS http://+:8080

# Full PGO
Expand Down
4 changes: 2 additions & 2 deletions frameworks/CSharp/aspnetcore/aspcore-ado-pg-up.dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM mcr.microsoft.com/dotnet/sdk:6.0.100 AS build
FROM mcr.microsoft.com/dotnet/sdk:7.0.100 AS build
WORKDIR /app
COPY PlatformBenchmarks .
RUN dotnet publish -c Release -o out /p:DatabaseProvider=Npgsql

FROM mcr.microsoft.com/dotnet/aspnet:6.0.0 AS runtime
FROM mcr.microsoft.com/dotnet/aspnet:7.0.0 AS runtime
ENV ASPNETCORE_URLS http://+:8080

# Full PGO
Expand Down
4 changes: 2 additions & 2 deletions frameworks/CSharp/aspnetcore/aspcore-ado-pg.dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM mcr.microsoft.com/dotnet/sdk:6.0.100 AS build
FROM mcr.microsoft.com/dotnet/sdk:7.0.100 AS build
WORKDIR /app
COPY PlatformBenchmarks .
RUN dotnet publish -c Release -o out /p:DatabaseProvider=Npgsql

FROM mcr.microsoft.com/dotnet/aspnet:6.0.0 AS runtime
FROM mcr.microsoft.com/dotnet/aspnet:7.0.0 AS runtime
ENV ASPNETCORE_URLS http://+:8080

# Full PGO
Expand Down
4 changes: 2 additions & 2 deletions frameworks/CSharp/aspnetcore/aspcore-mvc-ado-my.dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM mcr.microsoft.com/dotnet/sdk:6.0.100 AS build
FROM mcr.microsoft.com/dotnet/sdk:7.0.100 AS build
WORKDIR /app
COPY Benchmarks .
RUN dotnet publish -c Release -o out

FROM mcr.microsoft.com/dotnet/aspnet:6.0.0 AS runtime
FROM mcr.microsoft.com/dotnet/aspnet:7.0.0 AS runtime
ENV ASPNETCORE_URLS http://+:8080

# Full PGO
Expand Down
4 changes: 2 additions & 2 deletions frameworks/CSharp/aspnetcore/aspcore-mvc-ado-pg-up.dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM mcr.microsoft.com/dotnet/sdk:6.0.100 AS build
FROM mcr.microsoft.com/dotnet/sdk:7.0.100 AS build
WORKDIR /app
COPY Benchmarks .
RUN dotnet publish -c Release -o out

FROM mcr.microsoft.com/dotnet/aspnet:6.0.0 AS runtime
FROM mcr.microsoft.com/dotnet/aspnet:7.0.0 AS runtime
ENV ASPNETCORE_URLS http://+:8080

# Full PGO
Expand Down
4 changes: 2 additions & 2 deletions frameworks/CSharp/aspnetcore/aspcore-mvc-ado-pg.dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM mcr.microsoft.com/dotnet/sdk:6.0.100 AS build
FROM mcr.microsoft.com/dotnet/sdk:7.0.100 AS build
WORKDIR /app
COPY Benchmarks .
RUN dotnet publish -c Release -o out

FROM mcr.microsoft.com/dotnet/aspnet:6.0.0 AS runtime
FROM mcr.microsoft.com/dotnet/aspnet:7.0.0 AS runtime
ENV ASPNETCORE_URLS http://+:8080

# Full PGO
Expand Down
4 changes: 2 additions & 2 deletions frameworks/CSharp/aspnetcore/aspcore-mvc-dap-my.dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM mcr.microsoft.com/dotnet/sdk:6.0.100 AS build
FROM mcr.microsoft.com/dotnet/sdk:7.0.100 AS build
WORKDIR /app
COPY Benchmarks .
RUN dotnet publish -c Release -o out

FROM mcr.microsoft.com/dotnet/aspnet:6.0.0 AS runtime
FROM mcr.microsoft.com/dotnet/aspnet:7.0.0 AS runtime
ENV ASPNETCORE_URLS http://+:8080

# Full PGO
Expand Down
4 changes: 2 additions & 2 deletions frameworks/CSharp/aspnetcore/aspcore-mvc-dap-pg-up.dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM mcr.microsoft.com/dotnet/sdk:6.0.100 AS build
FROM mcr.microsoft.com/dotnet/sdk:7.0.100 AS build
WORKDIR /app
COPY Benchmarks .
RUN dotnet publish -c Release -o out

FROM mcr.microsoft.com/dotnet/aspnet:6.0.0 AS runtime
FROM mcr.microsoft.com/dotnet/aspnet:7.0.0 AS runtime
ENV ASPNETCORE_URLS http://+:8080

# Full PGO
Expand Down
Loading