Browse Source

Add EmbedIO (#6159)

* Add EmbedIO

* Set database type to 'None' because we do not require one
Andreas Nägeli 4 years ago
parent
commit
85068838fc

+ 38 - 0
frameworks/CSharp/embedio/.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

+ 23 - 0
frameworks/CSharp/embedio/Benchmarks/Benchmarks.csproj

@@ -0,0 +1,23 @@
+<Project Sdk="Microsoft.NET.Sdk">
+  
+  <PropertyGroup>
+    
+    <TargetFramework>net5.0</TargetFramework>
+    <LangVersion>9.0</LangVersion>
+    
+    <AssemblyTitle>EmbedIO Benchmarks</AssemblyTitle>
+    <Description>Test suite to be executed with TechEmpower FrameworkBenchmarks.</Description>
+    
+    <StartupObject>Benchmarks.Program</StartupObject>    
+    <OutputType>Exe</OutputType>
+    
+    <ServerGarbageCollection>true</ServerGarbageCollection>
+    <TieredCompilation>false</TieredCompilation>
+    
+  </PropertyGroup>
+  
+  <ItemGroup>
+    <PackageReference Include="EmbedIO" Version="3.4.3" />
+  </ItemGroup>
+  
+</Project>

+ 82 - 0
frameworks/CSharp/embedio/Benchmarks/Program.cs

@@ -0,0 +1,82 @@
+using EmbedIO;
+using Swan.Logging;
+using System;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Benchmarks
+{
+
+    #region Supporting data structures
+
+    public class JsonResult
+    {
+
+        public string Message { get; set; }
+
+    }
+
+    #endregion
+
+    public static class Program
+    {
+        private static readonly ManualResetEvent _WaitEvent = new ManualResetEvent(false);
+
+        public static async Task<int> Main(string[] args)
+        {
+            Logger.UnregisterLogger<ConsoleLogger>();
+
+            using var server = new WebServer(o => o
+                  .WithUrlPrefix("http://+:8080/")
+                  .WithMode(HttpListenerMode.EmbedIO))
+                .PreferNoCompressionFor("text/*")
+                .WithAction("/plaintext", HttpVerbs.Get, async (ctx) =>
+                {
+                    var bytes = Encoding.UTF8.GetBytes("Hello, World!");
+
+                    ctx.Response.ContentType = "text/plain";
+                    ctx.Response.ContentEncoding = Encoding.UTF8;
+                    ctx.Response.ContentLength64 = bytes.Length;
+
+                    await ctx.Response.OutputStream.WriteAsync(bytes, 0, bytes.Length);
+                })
+                .WithAction("/json", HttpVerbs.Get, async (ctx) =>
+                {
+                    var data = new JsonResult() { Message = "Hello, World!" };
+
+                    var serialized = Swan.Formatters.Json.Serialize(data);
+
+                    var bytes = Encoding.UTF8.GetBytes(serialized);
+
+                    ctx.Response.ContentType = "application/json";
+                    ctx.Response.ContentEncoding = Encoding.UTF8;
+                    ctx.Response.ContentLength64 = bytes.Length;
+
+                    await ctx.Response.OutputStream.WriteAsync(bytes, 0, bytes.Length);
+                });
+
+            try
+            {
+                AppDomain.CurrentDomain.ProcessExit += (_, __) =>
+                {
+                    _WaitEvent.Set();
+                };
+
+                await server.RunAsync();
+
+                _WaitEvent.WaitOne();
+
+                return 0;
+            }
+            catch (Exception e)
+            {
+                Console.WriteLine(e);
+
+                return -1;
+            }
+        }
+
+    }
+
+}

+ 22 - 0
frameworks/CSharp/embedio/README.md

@@ -0,0 +1,22 @@
+# EmbedIO Tests on Linux
+
+See the [project website](https://github.com/unosquare/embedio) for more information.
+
+## Infrastructure Software Versions
+
+**Language**
+
+* C# 9.0
+
+**Platforms**
+
+* .NET 5
+
+**Web Servers**
+
+* [EmbedIO](https://github.com/unosquare/embedio)
+
+## Paths & Source for Tests
+
+* [Plaintext](Benchmarks/Program.cs): "/plaintext"
+* [JSON](Benchmarks/Program.cs): "/json"

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

@@ -0,0 +1,22 @@
+{
+  "framework": "embedio",
+  "tests": [{
+    "default": {
+      "plaintext_url": "/plaintext",
+      "json_url": "/json",
+      "port": 8080,
+      "approach": "Realistic",
+      "classification": "Fullstack",
+      "database": "None",
+      "framework": "EmbedIO",
+      "language": "C#",
+      "orm": "Raw",
+      "platform": ".NET",
+      "webserver": "EmbedIO",
+      "os": "Linux",
+      "database_os": "Linux",
+      "display_name": "EmbedIO",
+      "notes": ""
+    }
+  }]
+}

+ 19 - 0
frameworks/CSharp/embedio/embedio.dockerfile

@@ -0,0 +1,19 @@
+FROM mcr.microsoft.com/dotnet/sdk:5.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
+
+# final stage/image
+FROM mcr.microsoft.com/dotnet/runtime-deps:5.0-alpine
+WORKDIR /app
+COPY --from=build /app .
+
+ENTRYPOINT ["./Benchmarks"]
+
+EXPOSE 8080