Browse Source

Switch to GenHTTP 2.8 and simplify program (#5505)

Andreas Nägeli 5 years ago
parent
commit
974889e0d4

+ 5 - 3
frameworks/CSharp/genhttp/Benchmarks/Benchmarks.csproj

@@ -2,7 +2,7 @@
   
   <PropertyGroup>
     
-    <TargetFramework>netcoreapp3.0</TargetFramework>
+    <TargetFramework>netcoreapp3.1</TargetFramework>
 
     <LangVersion>8.0</LangVersion>
     <Nullable>enable</Nullable>
@@ -13,11 +13,13 @@
     <StartupObject>Benchmarks.Program</StartupObject>    
     <OutputType>Exe</OutputType>
     
+    <ServerGarbageCollection>true</ServerGarbageCollection>
+    
   </PropertyGroup>
     
   <ItemGroup>
-    <PackageReference Include="GenHTTP.Core" Version="2.6.0" />
-    <PackageReference Include="GenHTTP.Modules.Webservices" Version="2.6.0" />
+    <PackageReference Include="GenHTTP.Core" Version="2.8.0" />
+    <PackageReference Include="GenHTTP.Modules.Webservices" Version="2.8.0" />
   </ItemGroup>
   
 </Project>

+ 8 - 29
frameworks/CSharp/genhttp/Benchmarks/Program.cs

@@ -16,35 +16,14 @@ namespace Benchmarks
 
         public static int Main(string[] args)
         {
-            try
-            {
-                var waitEvent = new AutoResetEvent(false);
-
-                AppDomain.CurrentDomain.ProcessExit += (s, e) =>
-                {
-                    waitEvent.Set();
-                };
-
-                var tests = Layout.Create()
-                                  .Add("plaintext", Content.From("Hello, World!"))
-                                  .Add<JsonResource>("json");
-
-                var server = Server.Create()
-                                   .Router(tests)
-                                   .Compression(false);
-
-                using (var instance = server.Build())
-                {
-                    waitEvent.WaitOne();
-                }
-
-                return 0;
-            }
-            catch (Exception e)
-            {
-                Console.WriteLine(e);
-                return -1;
-            }
+            var tests = Layout.Create()
+                              .Add("plaintext", Content.From("Hello, World!"))
+                              .Add<JsonResource>("json");
+
+            return Host.Create()
+                       .Router(tests)
+                       .Compression(false)
+                       .Run();
         }
 
     }

+ 2 - 2
frameworks/CSharp/genhttp/genhttp.dockerfile

@@ -1,4 +1,4 @@
-FROM mcr.microsoft.com/dotnet/core/sdk:3.0-alpine AS build
+FROM mcr.microsoft.com/dotnet/core/sdk:3.1-alpine AS build
 WORKDIR /app
 
 # copy csproj and restore as distinct layers
@@ -12,7 +12,7 @@ COPY Benchmarks/. ./Benchmarks/
 WORKDIR /app/Benchmarks
 RUN dotnet publish -c Release -r linux-musl-x64 -o out --self-contained true /p:PublishTrimmed=true
 
-FROM mcr.microsoft.com/dotnet/core/runtime-deps:3.0-alpine AS runtime
+FROM mcr.microsoft.com/dotnet/core/runtime-deps:3.1-alpine AS runtime
 ENV DOCKER_FLAVOR=linux
 WORKDIR /app
 COPY --from=build /app/Benchmarks/out ./