-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[genhttp] Update to Version 9 (#9404)
* Switch to .NET 9 but still on old GenHTTP version * Actually also switch the docker version * Migrate to GenHTTP 9 * Re-enable real data on fortunes * Switch to ASP.NET framework * one should compile before pushing .. * Another try * Use other docker file style * Encode HTML in fortunes * Assign ID 0 to additional cookie
- Loading branch information
1 parent
22d6674
commit 771117c
Showing
20 changed files
with
347 additions
and
448 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,38 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
|
||
<TargetFramework>net8.0</TargetFramework> | ||
<LangVersion>10.0</LangVersion> | ||
|
||
<AssemblyTitle>GenHTTP Benchmarks</AssemblyTitle> | ||
<Description>Test suite to be executed with TechEmpower FrameworkBenchmarks.</Description> | ||
|
||
<StartupObject>Benchmarks.Program</StartupObject> | ||
<OutputType>Exe</OutputType> | ||
|
||
<ServerGarbageCollection>true</ServerGarbageCollection> | ||
<TieredPGO>true</TieredPGO> | ||
|
||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<None Remove="Resources\Fortunes.html" /> | ||
<None Remove="Resources\Template.html" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<EmbeddedResource Include="Resources\Template.html" /> | ||
<EmbeddedResource Include="Resources\Fortunes.html" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
|
||
<PackageReference Include="GenHTTP.Core" Version="8.5.2" /> | ||
<PackageReference Include="GenHTTP.Modules.Razor" Version="8.5.0" /> | ||
<PackageReference Include="GenHTTP.Modules.Webservices" Version="8.5.0" /> | ||
|
||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.6" /> | ||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.4" /> | ||
|
||
</ItemGroup> | ||
|
||
|
||
<PropertyGroup> | ||
|
||
<TargetFramework>net9.0</TargetFramework> | ||
<LangVersion>13.0</LangVersion> | ||
<ImplicitUsings>true</ImplicitUsings> | ||
<OutputType>Exe</OutputType> | ||
|
||
<AssemblyTitle>GenHTTP Benchmarks</AssemblyTitle> | ||
<Description>Test suite to be executed with TechEmpower FrameworkBenchmarks.</Description> | ||
|
||
<ServerGarbageCollection>true</ServerGarbageCollection> | ||
<TieredPGO>true</TieredPGO> | ||
|
||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<None Remove="Resources\Fortunes.html"/> | ||
<None Remove="Resources\Template.html"/> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<EmbeddedResource Include="Resources\Template.html"/> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
|
||
<PackageReference Include="GenHTTP.Core.Kestrel" Version="9.0.0" /> | ||
<PackageReference Include="GenHTTP.Modules.Razor" Version="8.6.0" /> | ||
<PackageReference Include="GenHTTP.Modules.Webservices" Version="9.0.0" /> | ||
|
||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.0" /> | ||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.0" /> | ||
|
||
</ItemGroup> | ||
|
||
</Project> |
55 changes: 23 additions & 32 deletions
55
frameworks/CSharp/genhttp/Benchmarks/Model/DatabaseContext.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,43 @@ | ||
using Microsoft.EntityFrameworkCore; | ||
|
||
namespace Benchmarks.Model | ||
namespace Benchmarks.Model; | ||
|
||
public sealed class DatabaseContext : DbContext | ||
{ | ||
private static DbContextOptions<DatabaseContext> _options; | ||
|
||
public sealed class DatabaseContext : DbContext | ||
{ | ||
private static DbContextOptions<DatabaseContext> _Options; | ||
private static DbContextOptions<DatabaseContext> _noTrackingOptions; | ||
|
||
private static DbContextOptions<DatabaseContext> _NoTrackingOptions; | ||
#region Factory | ||
|
||
#region Factory | ||
public static DatabaseContext Create() => new(_options ??= GetOptions(true)); | ||
|
||
public static DatabaseContext Create() | ||
{ | ||
return new DatabaseContext(_Options ??= GetOptions(true)); | ||
} | ||
|
||
public static DatabaseContext CreateNoTracking() | ||
{ | ||
return new DatabaseContext(_NoTrackingOptions ??= GetOptions(false)); | ||
} | ||
public static DatabaseContext CreateNoTracking() => new(_noTrackingOptions ??= GetOptions(false)); | ||
|
||
private static DbContextOptions<DatabaseContext> GetOptions(bool tracking) | ||
{ | ||
var optionsBuilder = new DbContextOptionsBuilder<DatabaseContext>(); | ||
|
||
optionsBuilder.UseNpgsql("Server=tfb-database;Database=hello_world;User Id=benchmarkdbuser;Password=benchmarkdbpass;Maximum Pool Size=256;NoResetOnClose=true;Enlist=false;Max Auto Prepare=4"); | ||
private static DbContextOptions<DatabaseContext> GetOptions(bool tracking) | ||
{ | ||
var optionsBuilder = new DbContextOptionsBuilder<DatabaseContext>(); | ||
|
||
if (!tracking) | ||
{ | ||
optionsBuilder.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking); | ||
} | ||
optionsBuilder.UseNpgsql("Server=tfb-database;Database=hello_world;User Id=benchmarkdbuser;Password=benchmarkdbpass;SSL Mode=Disable;Maximum Pool Size=512;NoResetOnClose=true;Enlist=false;Max Auto Prepare=4"); | ||
|
||
return optionsBuilder.Options; | ||
if (!tracking) | ||
{ | ||
optionsBuilder.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking); | ||
} | ||
|
||
private DatabaseContext(DbContextOptions options) : base(options) { } | ||
return optionsBuilder.Options; | ||
} | ||
|
||
#endregion | ||
private DatabaseContext(DbContextOptions options) : base(options) { } | ||
|
||
#region Entities | ||
#endregion | ||
|
||
public DbSet<World> World { get; set; } | ||
#region Entities | ||
|
||
public DbSet<Fortune> Fortune { get; set; } | ||
public DbSet<World> World { get; set; } | ||
|
||
#endregion | ||
public DbSet<Fortune> Fortune { get; set; } | ||
|
||
} | ||
#endregion | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,17 @@ | ||
using System; | ||
using System.ComponentModel.DataAnnotations; | ||
using System.ComponentModel.DataAnnotations; | ||
using System.ComponentModel.DataAnnotations.Schema; | ||
|
||
namespace Benchmarks.Model | ||
{ | ||
|
||
[Table("fortune")] | ||
public class Fortune : IComparable<Fortune>, IComparable | ||
{ | ||
|
||
[Column("id")] | ||
public int ID { get; set; } | ||
namespace Benchmarks.Model; | ||
|
||
[Column("message")] | ||
[StringLength(2048)] | ||
public string Message { get; set; } | ||
|
||
public int CompareTo(object obj) => CompareTo((Fortune)obj); | ||
[Table("fortune")] | ||
public class Fortune | ||
{ | ||
|
||
public int CompareTo(Fortune other) => string.CompareOrdinal(Message, other.Message); | ||
[Column("id")] | ||
public int Id { get; set; } | ||
|
||
} | ||
[Column("message")] | ||
[StringLength(2048)] | ||
public string Message { get; set; } | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,15 @@ | ||
using System.ComponentModel.DataAnnotations.Schema; | ||
|
||
namespace Benchmarks.Model | ||
{ | ||
|
||
[Table("world")] | ||
public class World | ||
{ | ||
namespace Benchmarks.Model; | ||
|
||
[Column("id")] | ||
public int Id { get; set; } | ||
[Table("world")] | ||
public class World | ||
{ | ||
|
||
[Column("randomnumber")] | ||
public int RandomNumber { get; set; } | ||
[Column("id")] | ||
public int Id { get; set; } | ||
|
||
} | ||
[Column("randomnumber")] | ||
public int RandomNumber { get; set; } | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,20 @@ | ||
using GenHTTP.Engine; | ||
|
||
using Benchmarks.Tests; | ||
using Benchmarks.Utilities; | ||
using GenHTTP.Engine.Kestrel; | ||
using GenHTTP.Modules.IO; | ||
using GenHTTP.Modules.Layouting; | ||
using GenHTTP.Modules.Webservices; | ||
|
||
using Benchmarks.Tests; | ||
using Benchmarks.Utilities; | ||
|
||
namespace Benchmarks | ||
{ | ||
|
||
public static class Program | ||
{ | ||
|
||
public static int Main(string[] args) | ||
{ | ||
var tests = Layout.Create() | ||
.Add("plaintext", Content.From(Resource.FromString("Hello, World!"))) | ||
.Add("fortunes", new FortuneHandlerBuilder()) | ||
.AddService<JsonResource>("json") | ||
.AddService<DbResource>("db") | ||
.AddService<QueryResource>("queries") | ||
.AddService<UpdateResource>("updates") | ||
.AddService<CacheResource>("cached-worlds") | ||
.Add(ServerHeader.Create()); | ||
|
||
return Host.Create() | ||
.Handler(tests) | ||
.Run(); | ||
} | ||
|
||
} | ||
|
||
} | ||
var tests = Layout.Create() | ||
.Add("plaintext", Content.From(Resource.FromString("Hello, World!"))) | ||
.Add("fortunes", new FortuneHandler()) | ||
.AddService<JsonResource>("json") | ||
.AddService<DbResource>("db") | ||
.AddService<QueryResource>("queries") | ||
.AddService<UpdateResource>("updates") | ||
.AddService<CacheResource>("cached-worlds") | ||
.Add(ServerHeader.Create()); | ||
|
||
return await Host.Create() | ||
.Handler(tests) | ||
.RunAsync(); |
This file was deleted.
Oops, something went wrong.
19 changes: 16 additions & 3 deletions
19
frameworks/CSharp/genhttp/Benchmarks/Resources/Template.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,22 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>@Model.Meta.Title</title> | ||
<title>Fortunes</title> | ||
</head> | ||
<body> | ||
@Model.Content | ||
|
||
<table> | ||
<tr> | ||
<th>id</th> | ||
<th>message</th> | ||
</tr> | ||
{for cookie in cookies: | ||
<tr> | ||
<td>{ cookie.id }</td> | ||
<td>{ cookie.message }</td> | ||
</tr> | ||
} | ||
</table> | ||
|
||
</body> | ||
</html> | ||
</html> |
Oops, something went wrong.