Skip to content

Commit fdca6a2

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents ab35c83 + 53e2e9d commit fdca6a2

File tree

81 files changed

+6161
-206
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+6161
-206
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Celerio Benchmarks
2+
3+
Celerio is a modern C# framework designed for high-performance web applications based on Source Generation **only**.
4+
This benchmark tests Celerio using the standard TechEmpower FrameworkBenchmarks suite.
5+
6+
## Links
7+
8+
- [GitHub](https://github.com/Oxule/Celerio)
9+
- [NuGet](https://www.nuget.org/packages/Celerio)
10+
11+
## Infrastructure Software Versions
12+
13+
- C# 12
14+
- .NET 8
15+
16+
## Benchmarks Included
17+
18+
- **Plaintext**
19+
- **JSON**
20+
21+
## Author
22+
23+
* [Oxule](https://github.com/Oxule)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"framework": "celerio",
3+
"tests": [
4+
{
5+
"default": {
6+
"json_url": "/json",
7+
"plaintext_url": "/plaintext",
8+
"port": 8080,
9+
"approach": "Realistic",
10+
"classification": "Micro",
11+
"database": "None",
12+
"framework": "Celerio",
13+
"language": "CSharp",
14+
"flavor": "None",
15+
"orm": "None",
16+
"platform": ".NET",
17+
"webserver": "Celerio",
18+
"os": "Linux",
19+
"database_os": "Linux",
20+
"display_name": "Celerio",
21+
"notes": "",
22+
"versus": "aspcore-mvc"
23+
}
24+
}
25+
]
26+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FROM mcr.microsoft.com/dotnet/runtime:8.0 AS base
2+
USER $APP_UID
3+
WORKDIR /app
4+
5+
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
6+
ARG BUILD_CONFIGURATION=Release
7+
WORKDIR /src
8+
COPY ["src/src.csproj", "src/"]
9+
RUN dotnet restore "src/src.csproj"
10+
COPY . .
11+
WORKDIR "/src/src"
12+
RUN dotnet build "./src.csproj" -c $BUILD_CONFIGURATION -o /app/build
13+
14+
FROM build AS publish
15+
ARG BUILD_CONFIGURATION=Release
16+
RUN dotnet publish "./src.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
17+
18+
FROM base AS final
19+
WORKDIR /app
20+
COPY --from=publish /app/publish .
21+
22+
EXPOSE 8080
23+
24+
ENTRYPOINT ["dotnet", "src.dll"]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[framework]
2+
name = "celerio"
3+
4+
[main]
5+
urls.plaintext = "/plaintext"
6+
urls.json = "/json"
7+
approach = "Realistic"
8+
classification = "Micro"
9+
database = "None"
10+
database_os = "Linux"
11+
os = "Linux"
12+
orm = "None"
13+
platform = ".NET"
14+
webserver = "Celerio"
15+
versus = "aspcore-mvc"
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
**/.dockerignore
2+
**/.env
3+
**/.git
4+
**/.gitignore
5+
**/.project
6+
**/.settings
7+
**/.toolstarget
8+
**/.vs
9+
**/.vscode
10+
**/.idea
11+
**/*.*proj.user
12+
**/*.dbmdl
13+
**/*.jfm
14+
**/azds.yaml
15+
**/bin
16+
**/charts
17+
**/docker-compose*
18+
**/Dockerfile*
19+
**/node_modules
20+
**/npm-debug.log
21+
**/obj
22+
**/secrets.dev.yaml
23+
**/values.dev.yaml
24+
LICENSE
25+
README.md
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
namespace src;
2+
3+
using Celerio;
4+
using static Celerio.Result;
5+
6+
public static class Endpoints
7+
{
8+
[Get("/plaintext")]
9+
public static Result Plaintext()
10+
{
11+
return Ok().Text("Hello, World!");
12+
}
13+
14+
[Serializable]
15+
public class SampleResponse
16+
{
17+
public string message { get; set; } = "Hello, World!";
18+
}
19+
20+
[Get("/json")]
21+
public static Result Json()
22+
{
23+
return Ok().Json(new SampleResponse());
24+
}
25+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
using System.Net;
2+
using Celerio.Generated;
3+
4+
var server = new Server(IPAddress.Any, 8080);
5+
server.Start();
6+
await Task.Delay(Timeout.Infinite);
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<LangVersion>preview</LangVersion>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<Nullable>enable</Nullable>
9+
<!--<PublishAot>true</PublishAot>-->
10+
<InvariantGlobalization>true</InvariantGlobalization>
11+
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
12+
</PropertyGroup>
13+
14+
<ItemGroup>
15+
<PackageReference Include="Celerio" Version="2.0.0-preview.1" />
16+
</ItemGroup>
17+
18+
</Project>

frameworks/CSharp/touchsocket/src/TouchSocketHttp/Program.cs

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,25 @@
22
using TouchSocket.Core;
33
using TouchSocket.Http;
44
using TouchSocket.Sockets;
5-
using static System.Net.Mime.MediaTypeNames;
65
using HttpContent = TouchSocket.Http.HttpContent;
76

87
namespace TouchSocketHttp;
98

109
public class Program
1110
{
12-
static async Task Main(string[] args)
11+
private static async Task Main(string[] args)
1312
{
1413
int port = 8080;
15-
16-
Console.WriteLine(DateHelper.DateString);
17-
var service = new MyHttpService();
14+
MyHttpService service = new MyHttpService();
1815

1916
await service.SetupAsync(new TouchSocketConfig()
2017
.SetListenIPHosts(port)
2118
.SetNoDelay(true)
19+
.SetTransportOption(options =>
20+
{
21+
options.ReceivePipeOptions = TransportOption.CreateSchedulerOptimizedPipeOptions();
22+
options.SendPipeOptions = TransportOption.CreateSchedulerOptimizedPipeOptions();
23+
})
2224
.SetMaxCount(1000000)
2325
.SetBacklog(1000)
2426
.ConfigureContainer(a =>
@@ -35,42 +37,42 @@ await service.SetupAsync(new TouchSocketConfig()
3537
}
3638
}
3739

38-
sealed class MyHttpService : HttpService<MyHttpSessionClient>
40+
internal sealed class MyHttpService : HttpService<MyHttpSessionClient>
3941
{
4042
protected override MyHttpSessionClient NewClient()
4143
{
4244
return new MyHttpSessionClient();
4345
}
4446
}
4547

46-
sealed class MyHttpSessionClient : HttpSessionClient
48+
internal sealed class MyHttpSessionClient : HttpSessionClient
4749
{
48-
private readonly HttpContent m_contentPlaintext = new StringHttpContent("Hello, World!", Encoding.UTF8, $"text/plain");
49-
private readonly HttpContent m_contentJson = new StringHttpContent("{\"message\":\"Hello, World!\"}", Encoding.UTF8, $"application/json");
50+
private readonly HttpContent m_contentPlaintext = new StringHttpContent("Hello, World!", Encoding.UTF8, "text/plain");
51+
private readonly HttpContent m_contentJson = new StringHttpContent("{\"message\":\"Hello, World!\"}", Encoding.UTF8, "application/json");
5052

5153
protected override async Task OnReceivedHttpRequest(HttpContext httpContext)
5254
{
53-
var request = httpContext.Request;
54-
var response = httpContext.Response;
55+
HttpRequest request = httpContext.Request;
56+
HttpResponse response = httpContext.Response;
5557

5658
switch (request.RelativeURL)
5759
{
5860
case "/plaintext":
5961
{
6062
response.StatusCode = 200;
61-
response.StatusMessage = "success";
63+
response.StatusMessage = "ok";
6264
response.Headers.Add(HttpHeaders.Server, "T");
63-
response.Headers.Add(HttpHeaders.Date, DateHelper.DateString);
65+
response.Headers.Add(HttpHeaders.Date, HttpExtensions.CurrentHttpDate);
6466
response.Content = m_contentPlaintext;
6567
await response.AnswerAsync().ConfigureAwait(false);
6668
}
6769
break;
6870
case "/json":
6971
{
7072
response.StatusCode = 200;
71-
response.StatusMessage = "success";
73+
response.StatusMessage = "ok";
7274
response.Headers.Add(HttpHeaders.Server, "T");
73-
response.Headers.Add(HttpHeaders.Date, DateHelper.DateString);
75+
response.Headers.Add(HttpHeaders.Date, HttpExtensions.CurrentHttpDate);
7476
response.Content = m_contentJson;
7577
await response.AnswerAsync().ConfigureAwait(false);
7678
}
@@ -81,19 +83,4 @@ protected override async Task OnReceivedHttpRequest(HttpContext httpContext)
8183
break;
8284
}
8385
}
84-
}
85-
86-
static class DateHelper
87-
{
88-
static Timer m_timer;
89-
static DateHelper()
90-
{
91-
m_timer = new Timer((state) =>
92-
{
93-
DateString = DateTime.UtcNow.ToGMTString();
94-
}, null, 0, 1000);
95-
}
96-
97-
public static string DateString { get; private set; }
98-
}
99-
86+
}

frameworks/CSharp/touchsocket/src/TouchSocketHttp/TouchSocketHttp.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@
1212
</PropertyGroup>
1313

1414
<ItemGroup>
15-
<PackageReference Include="TouchSocket.Http" Version="4.0.0-beta.57" />
15+
<PackageReference Include="TouchSocket.Http" Version="4.0.0-beta.80" />
1616
</ItemGroup>
1717
</Project>

0 commit comments

Comments
 (0)