Selaa lähdekoodia

Add simplew framework (#10237)

* Add SimpleW frameowork

* set readme

* rename controller

* fix message typo

* Remove compression, add date headers

* Remove compression, add date headers
Diogo Martins 1 kuukausi sitten
vanhempi
sitoutus
136a9a668c

+ 38 - 0
frameworks/CSharp/simplew/.gitignore

@@ -0,0 +1,38 @@
+[Oo]bj/
+[Bb]in/
+TestResults/
+.nuget/
+*.sln
+*.sln.ide/
+_ReSharper.*/
+.idea/
+packages/
+artifacts/
+PublishProfiles/
+.vs/
+*.user
+*.suo
+*.cache
+*.docstates
+_ReSharper.*
+nuget.exe
+*net45.csproj
+*net451.csproj
+*k10.csproj
+*.psess
+*.vsp
+*.pidb
+*.userprefs
+*DS_Store
+*.ncrunchsolution
+*.*sdf
+*.ipch
+*.swp
+*~
+.build/
+.testPublish/
+launchSettings.json
+BenchmarkDotNet.Artifacts/
+BDN.Generated/
+binaries/
+global.json

+ 20 - 0
frameworks/CSharp/simplew/Benchmarks/Benchmarks.csproj

@@ -0,0 +1,20 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+    <PropertyGroup>
+        <OutputType>Exe</OutputType>
+        <TargetFramework>net9.0</TargetFramework>
+        <ImplicitUsings>enable</ImplicitUsings>
+        <Nullable>enable</Nullable>
+        <RootNamespace>SimpleW</RootNamespace>
+
+        <ServerGarbageCollection>true</ServerGarbageCollection>
+        <TieredPGO>true</TieredPGO>
+
+        <RuntimeIdentifier>linux-musl-x64</RuntimeIdentifier>
+    </PropertyGroup>
+
+    <ItemGroup>
+      <PackageReference Include="SimpleW" Version="16.1.0" />
+    </ItemGroup>
+
+</Project>

+ 48 - 0
frameworks/CSharp/simplew/Benchmarks/Program.cs

@@ -0,0 +1,48 @@
+using System;
+using System.Buffers.Text;
+using System.Net;
+using System.Threading.Tasks;
+using SimpleW;
+
+namespace Benchmarks;
+
+internal static class Program
+{
+    public static async Task Main(string[] args)
+    {
+        var server = new SimpleWServer(IPAddress.Any, 8080);
+        server.AddDynamicContent("/api");
+        server.Start();
+        
+        await Task.Delay(-1);
+    }
+    
+    public class BenchmarksController : Controller {
+        [Route("GET", "/json")]
+        public object Json() {
+            return Response.MakeResponse(
+                new { message = "Hello, World!" }, // object will be serialized
+                addHeaders: new Dictionary<string, string>()
+                {
+                    { "Server", "SimpleW" },
+                    { "Date", DateTime.Now.ToString("R") }
+                }
+                // compress parameter is default to null, so no compression
+            );
+        }
+
+        [Route("GET", "/plaintext")]
+        public object Plaintext() {
+            return Response.MakeResponse(
+                "Hello, World!",
+                "text/plain",
+                addHeaders: new Dictionary<string, string>()
+                {
+                    { "Server", "SimpleW" },
+                    { "Date", DateTime.Now.ToString("R") }
+                }
+                // compress parameter is default to null, so no compression
+            );
+        }
+    }
+}

+ 18 - 0
frameworks/CSharp/simplew/README.md

@@ -0,0 +1,18 @@
+# SimpleW Tests on Linux
+
+See the [SimpleW website](https://stratdev3.github.io/SimpleW/) for more information.
+
+## Infrastructure Software Versions
+
+**Language**
+
+* C# 13.0
+
+**Platforms**
+
+* .NET 8/9
+
+## Paths & Source for Tests
+
+* [Plaintext](Benchmarks/Program.cs): "/api/plaintext"
+* [JSON](Benchmarks/Tests/JsonResource.cs): "/api/json"

+ 22 - 0
frameworks/CSharp/simplew/benchmark_config.json

@@ -0,0 +1,22 @@
+{
+  "framework": "simplew",
+  "tests": [{
+    "default": {
+      "plaintext_url": "/api/plaintext",
+        "json_url": "/api/json",
+        "port": 8080,
+        "approach": "Realistic",
+        "classification": "Fullstack",
+        "database": "None",
+        "framework": "SimpleW",
+        "language": "C#",
+        "orm": "None",
+        "platform": ".NET",
+        "webserver": "Netcoreserver",
+        "os": "Linux",
+        "database_os": "Linux",
+        "display_name": "SimpleW",
+        "notes": "Only plaintext and JSON benchmarks implemented yet"
+    }
+  }]
+}

+ 14 - 0
frameworks/CSharp/simplew/config.toml

@@ -0,0 +1,14 @@
+[framework]
+name = "simplew"
+
+[main]
+urls.plaintext = "/api/plaintext"
+urls.json = "/api/json"
+approach = "Realistic"
+classification = "Fullstack"
+os = "Linux"
+database_os = "Linux"
+orm = "None"
+platform = ".NET"
+webserver = "Netcoreserver"
+versus = "None"

+ 24 - 0
frameworks/CSharp/simplew/simplew.dockerfile

@@ -0,0 +1,24 @@
+FROM mcr.microsoft.com/dotnet/sdk:9.0-alpine AS build
+WORKDIR /source
+
+# 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:9.0-alpine
+
+ENV DOTNET_GCDynamicAdaptationMode=0
+ENV DOTNET_ReadyToRun=0
+ENV DOTNET_HillClimbing_Disable=1
+
+WORKDIR /app
+COPY --from=build /app .
+
+ENTRYPOINT ["./Benchmarks"]
+
+EXPOSE 8080