Skip to content

Commit 136a9a6

Browse files
authored
Add simplew framework (#10237)
* Add SimpleW frameowork * set readme * rename controller * fix message typo * Remove compression, add date headers * Remove compression, add date headers
1 parent 4d76793 commit 136a9a6

File tree

7 files changed

+184
-0
lines changed

7 files changed

+184
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
[Oo]bj/
2+
[Bb]in/
3+
TestResults/
4+
.nuget/
5+
*.sln
6+
*.sln.ide/
7+
_ReSharper.*/
8+
.idea/
9+
packages/
10+
artifacts/
11+
PublishProfiles/
12+
.vs/
13+
*.user
14+
*.suo
15+
*.cache
16+
*.docstates
17+
_ReSharper.*
18+
nuget.exe
19+
*net45.csproj
20+
*net451.csproj
21+
*k10.csproj
22+
*.psess
23+
*.vsp
24+
*.pidb
25+
*.userprefs
26+
*DS_Store
27+
*.ncrunchsolution
28+
*.*sdf
29+
*.ipch
30+
*.swp
31+
*~
32+
.build/
33+
.testPublish/
34+
launchSettings.json
35+
BenchmarkDotNet.Artifacts/
36+
BDN.Generated/
37+
binaries/
38+
global.json
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net9.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
<RootNamespace>SimpleW</RootNamespace>
9+
10+
<ServerGarbageCollection>true</ServerGarbageCollection>
11+
<TieredPGO>true</TieredPGO>
12+
13+
<RuntimeIdentifier>linux-musl-x64</RuntimeIdentifier>
14+
</PropertyGroup>
15+
16+
<ItemGroup>
17+
<PackageReference Include="SimpleW" Version="16.1.0" />
18+
</ItemGroup>
19+
20+
</Project>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
using System;
2+
using System.Buffers.Text;
3+
using System.Net;
4+
using System.Threading.Tasks;
5+
using SimpleW;
6+
7+
namespace Benchmarks;
8+
9+
internal static class Program
10+
{
11+
public static async Task Main(string[] args)
12+
{
13+
var server = new SimpleWServer(IPAddress.Any, 8080);
14+
server.AddDynamicContent("/api");
15+
server.Start();
16+
17+
await Task.Delay(-1);
18+
}
19+
20+
public class BenchmarksController : Controller {
21+
[Route("GET", "/json")]
22+
public object Json() {
23+
return Response.MakeResponse(
24+
new { message = "Hello, World!" }, // object will be serialized
25+
addHeaders: new Dictionary<string, string>()
26+
{
27+
{ "Server", "SimpleW" },
28+
{ "Date", DateTime.Now.ToString("R") }
29+
}
30+
// compress parameter is default to null, so no compression
31+
);
32+
}
33+
34+
[Route("GET", "/plaintext")]
35+
public object Plaintext() {
36+
return Response.MakeResponse(
37+
"Hello, World!",
38+
"text/plain",
39+
addHeaders: new Dictionary<string, string>()
40+
{
41+
{ "Server", "SimpleW" },
42+
{ "Date", DateTime.Now.ToString("R") }
43+
}
44+
// compress parameter is default to null, so no compression
45+
);
46+
}
47+
}
48+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# SimpleW Tests on Linux
2+
3+
See the [SimpleW website](https://stratdev3.github.io/SimpleW/) for more information.
4+
5+
## Infrastructure Software Versions
6+
7+
**Language**
8+
9+
* C# 13.0
10+
11+
**Platforms**
12+
13+
* .NET 8/9
14+
15+
## Paths & Source for Tests
16+
17+
* [Plaintext](Benchmarks/Program.cs): "/api/plaintext"
18+
* [JSON](Benchmarks/Tests/JsonResource.cs): "/api/json"
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"framework": "simplew",
3+
"tests": [{
4+
"default": {
5+
"plaintext_url": "/api/plaintext",
6+
"json_url": "/api/json",
7+
"port": 8080,
8+
"approach": "Realistic",
9+
"classification": "Fullstack",
10+
"database": "None",
11+
"framework": "SimpleW",
12+
"language": "C#",
13+
"orm": "None",
14+
"platform": ".NET",
15+
"webserver": "Netcoreserver",
16+
"os": "Linux",
17+
"database_os": "Linux",
18+
"display_name": "SimpleW",
19+
"notes": "Only plaintext and JSON benchmarks implemented yet"
20+
}
21+
}]
22+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[framework]
2+
name = "simplew"
3+
4+
[main]
5+
urls.plaintext = "/api/plaintext"
6+
urls.json = "/api/json"
7+
approach = "Realistic"
8+
classification = "Fullstack"
9+
os = "Linux"
10+
database_os = "Linux"
11+
orm = "None"
12+
platform = ".NET"
13+
webserver = "Netcoreserver"
14+
versus = "None"
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FROM mcr.microsoft.com/dotnet/sdk:9.0-alpine AS build
2+
WORKDIR /source
3+
4+
# copy csproj and restore as distinct layers
5+
COPY Benchmarks/*.csproj .
6+
RUN dotnet restore -r linux-musl-x64
7+
8+
# copy and publish app and libraries
9+
COPY Benchmarks/ .
10+
RUN dotnet publish -c release -o /app -r linux-musl-x64 --no-restore --self-contained
11+
12+
# final stage/image
13+
FROM mcr.microsoft.com/dotnet/runtime-deps:9.0-alpine
14+
15+
ENV DOTNET_GCDynamicAdaptationMode=0
16+
ENV DOTNET_ReadyToRun=0
17+
ENV DOTNET_HillClimbing_Disable=1
18+
19+
WORKDIR /app
20+
COPY --from=build /app .
21+
22+
ENTRYPOINT ["./Benchmarks"]
23+
24+
EXPOSE 8080

0 commit comments

Comments
 (0)