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
4 changes: 2 additions & 2 deletions frameworks/CSharp/carter/Benchmarks/Benchmarks.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<NoDefaultLaunchSettingsFile>true</NoDefaultLaunchSettingsFile>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Carter" Version="5.2.0" />
<PackageReference Include="Carter" Version="10.0.0" />
<PackageReference Include="Utf8Json" Version="1.3.7" />
</ItemGroup>
</Project>
30 changes: 16 additions & 14 deletions frameworks/CSharp/carter/Benchmarks/JsonModule.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
namespace Benchmarks
{
using Carter;
using System.Threading.Tasks;
using Utf8Json;
using Carter;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
using Utf8Json;

public class JsonModule : CarterModule
namespace Benchmarks
{
public class JsonModule : ICarterModule
{
private const int _bufferSize = 27;

public JsonModule() : base("json")
public struct JsonMessage
{
public string message;
}

public void AddRoutes(IEndpointRouteBuilder app)
{
Get("/", (req, res) =>
app.MapGet("/json", (HttpResponse res) =>
{
res.StatusCode = 200;
res.ContentType = "application/json";
Expand All @@ -21,10 +28,5 @@ public JsonModule() : base("json")
return JsonSerializer.SerializeAsync(res.Body, msg);
});
}

public struct JsonMessage
{
public string message;
}
}
}
}
20 changes: 12 additions & 8 deletions frameworks/CSharp/carter/Benchmarks/PlainModule.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
namespace Benchmarks
{
using Carter;
using System.Text;
using System.Text;
using Carter;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;

public class PlainModule : CarterModule
namespace Benchmarks
{
public class PlainModule : ICarterModule
{
private static readonly byte[] _helloWorldPayload = Encoding.UTF8.GetBytes("Hello, World!");

public PlainModule() : base("plaintext")

public void AddRoutes(IEndpointRouteBuilder app)
{
Get("/", (req, res) =>
app.MapGet("/plaintext", (HttpResponse res) =>
{
var payloadLength = _helloWorldPayload.Length;
res.StatusCode = 200;
Expand All @@ -19,4 +23,4 @@ public PlainModule() : base("plaintext")
});
}
}
}
}
34 changes: 10 additions & 24 deletions frameworks/CSharp/carter/Benchmarks/Program.cs
Original file line number Diff line number Diff line change
@@ -1,27 +1,13 @@
namespace Benchmarks
{
using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Carter;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Logging;

public class Program
{
public static async Task Main(string[] args)
{
var config = new ConfigurationBuilder()
.AddEnvironmentVariables(prefix: "ASPNETCORE_")
.AddCommandLine(args)
.Build();
var builder = WebApplication.CreateBuilder(args);

var webHost = new WebHostBuilder()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseConfiguration(config)
.UseStartup<Startup>()
.UseKestrel()
.Build();
// Disable logging as this is not required for the benchmark
builder.Logging.ClearProviders();
builder.Services.AddCarter();
var app = builder.Build();

await webHost.RunAsync();
}
}
}
app.MapCarter();
app.Run();
20 changes: 0 additions & 20 deletions frameworks/CSharp/carter/Benchmarks/Startup.cs

This file was deleted.

2 changes: 1 addition & 1 deletion frameworks/CSharp/carter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This includes tests for plaintext and json serialization.

**Language**

* C# 7.0
* C# 14.0

**Platforms**

Expand Down
4 changes: 2 additions & 2 deletions frameworks/CSharp/carter/carter.dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
WORKDIR /app
COPY Benchmarks .
RUN dotnet publish -c Release -o out

FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS runtime
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS runtime
ENV ASPNETCORE_URLS http://+:8080
WORKDIR /app
COPY --from=build /app/out ./
Expand Down
Loading