Skip to content

Commit 771117c

Browse files
[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
1 parent 22d6674 commit 771117c

20 files changed

+347
-448
lines changed
Lines changed: 36 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,38 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2-
3-
<PropertyGroup>
4-
5-
<TargetFramework>net8.0</TargetFramework>
6-
<LangVersion>10.0</LangVersion>
7-
8-
<AssemblyTitle>GenHTTP Benchmarks</AssemblyTitle>
9-
<Description>Test suite to be executed with TechEmpower FrameworkBenchmarks.</Description>
10-
11-
<StartupObject>Benchmarks.Program</StartupObject>
12-
<OutputType>Exe</OutputType>
13-
14-
<ServerGarbageCollection>true</ServerGarbageCollection>
15-
<TieredPGO>true</TieredPGO>
16-
17-
</PropertyGroup>
18-
19-
<ItemGroup>
20-
<None Remove="Resources\Fortunes.html" />
21-
<None Remove="Resources\Template.html" />
22-
</ItemGroup>
23-
24-
<ItemGroup>
25-
<EmbeddedResource Include="Resources\Template.html" />
26-
<EmbeddedResource Include="Resources\Fortunes.html" />
27-
</ItemGroup>
28-
29-
<ItemGroup>
30-
31-
<PackageReference Include="GenHTTP.Core" Version="8.5.2" />
32-
<PackageReference Include="GenHTTP.Modules.Razor" Version="8.5.0" />
33-
<PackageReference Include="GenHTTP.Modules.Webservices" Version="8.5.0" />
34-
35-
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.6" />
36-
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.4" />
37-
38-
</ItemGroup>
39-
2+
3+
<PropertyGroup>
4+
5+
<TargetFramework>net9.0</TargetFramework>
6+
<LangVersion>13.0</LangVersion>
7+
<ImplicitUsings>true</ImplicitUsings>
8+
<OutputType>Exe</OutputType>
9+
10+
<AssemblyTitle>GenHTTP Benchmarks</AssemblyTitle>
11+
<Description>Test suite to be executed with TechEmpower FrameworkBenchmarks.</Description>
12+
13+
<ServerGarbageCollection>true</ServerGarbageCollection>
14+
<TieredPGO>true</TieredPGO>
15+
16+
</PropertyGroup>
17+
18+
<ItemGroup>
19+
<None Remove="Resources\Fortunes.html"/>
20+
<None Remove="Resources\Template.html"/>
21+
</ItemGroup>
22+
23+
<ItemGroup>
24+
<EmbeddedResource Include="Resources\Template.html"/>
25+
</ItemGroup>
26+
27+
<ItemGroup>
28+
29+
<PackageReference Include="GenHTTP.Core.Kestrel" Version="9.0.0" />
30+
<PackageReference Include="GenHTTP.Modules.Razor" Version="8.6.0" />
31+
<PackageReference Include="GenHTTP.Modules.Webservices" Version="9.0.0" />
32+
33+
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.0" />
34+
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.0" />
35+
36+
</ItemGroup>
37+
4038
</Project>
Lines changed: 23 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,43 @@
11
using Microsoft.EntityFrameworkCore;
22

3-
namespace Benchmarks.Model
3+
namespace Benchmarks.Model;
4+
5+
public sealed class DatabaseContext : DbContext
46
{
7+
private static DbContextOptions<DatabaseContext> _options;
58

6-
public sealed class DatabaseContext : DbContext
7-
{
8-
private static DbContextOptions<DatabaseContext> _Options;
9+
private static DbContextOptions<DatabaseContext> _noTrackingOptions;
910

10-
private static DbContextOptions<DatabaseContext> _NoTrackingOptions;
11+
#region Factory
1112

12-
#region Factory
13+
public static DatabaseContext Create() => new(_options ??= GetOptions(true));
1314

14-
public static DatabaseContext Create()
15-
{
16-
return new DatabaseContext(_Options ??= GetOptions(true));
17-
}
18-
19-
public static DatabaseContext CreateNoTracking()
20-
{
21-
return new DatabaseContext(_NoTrackingOptions ??= GetOptions(false));
22-
}
15+
public static DatabaseContext CreateNoTracking() => new(_noTrackingOptions ??= GetOptions(false));
2316

24-
private static DbContextOptions<DatabaseContext> GetOptions(bool tracking)
25-
{
26-
var optionsBuilder = new DbContextOptionsBuilder<DatabaseContext>();
27-
28-
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");
17+
private static DbContextOptions<DatabaseContext> GetOptions(bool tracking)
18+
{
19+
var optionsBuilder = new DbContextOptionsBuilder<DatabaseContext>();
2920

30-
if (!tracking)
31-
{
32-
optionsBuilder.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking);
33-
}
21+
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");
3422

35-
return optionsBuilder.Options;
23+
if (!tracking)
24+
{
25+
optionsBuilder.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking);
3626
}
3727

38-
private DatabaseContext(DbContextOptions options) : base(options) { }
28+
return optionsBuilder.Options;
29+
}
3930

40-
#endregion
31+
private DatabaseContext(DbContextOptions options) : base(options) { }
4132

42-
#region Entities
33+
#endregion
4334

44-
public DbSet<World> World { get; set; }
35+
#region Entities
4536

46-
public DbSet<Fortune> Fortune { get; set; }
37+
public DbSet<World> World { get; set; }
4738

48-
#endregion
39+
public DbSet<Fortune> Fortune { get; set; }
4940

50-
}
41+
#endregion
5142

5243
}
Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,17 @@
1-
using System;
2-
using System.ComponentModel.DataAnnotations;
1+
using System.ComponentModel.DataAnnotations;
32
using System.ComponentModel.DataAnnotations.Schema;
43

5-
namespace Benchmarks.Model
6-
{
7-
8-
[Table("fortune")]
9-
public class Fortune : IComparable<Fortune>, IComparable
10-
{
11-
12-
[Column("id")]
13-
public int ID { get; set; }
4+
namespace Benchmarks.Model;
145

15-
[Column("message")]
16-
[StringLength(2048)]
17-
public string Message { get; set; }
18-
19-
public int CompareTo(object obj) => CompareTo((Fortune)obj);
6+
[Table("fortune")]
7+
public class Fortune
8+
{
209

21-
public int CompareTo(Fortune other) => string.CompareOrdinal(Message, other.Message);
10+
[Column("id")]
11+
public int Id { get; set; }
2212

23-
}
13+
[Column("message")]
14+
[StringLength(2048)]
15+
public string Message { get; set; }
2416

2517
}
Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
using System.ComponentModel.DataAnnotations.Schema;
22

3-
namespace Benchmarks.Model
4-
{
5-
6-
[Table("world")]
7-
public class World
8-
{
3+
namespace Benchmarks.Model;
94

10-
[Column("id")]
11-
public int Id { get; set; }
5+
[Table("world")]
6+
public class World
7+
{
128

13-
[Column("randomnumber")]
14-
public int RandomNumber { get; set; }
9+
[Column("id")]
10+
public int Id { get; set; }
1511

16-
}
12+
[Column("randomnumber")]
13+
public int RandomNumber { get; set; }
1714

18-
}
15+
}
Lines changed: 16 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,20 @@
1-
using GenHTTP.Engine;
2-
1+
using Benchmarks.Tests;
2+
using Benchmarks.Utilities;
3+
using GenHTTP.Engine.Kestrel;
34
using GenHTTP.Modules.IO;
45
using GenHTTP.Modules.Layouting;
56
using GenHTTP.Modules.Webservices;
67

7-
using Benchmarks.Tests;
8-
using Benchmarks.Utilities;
9-
10-
namespace Benchmarks
11-
{
12-
13-
public static class Program
14-
{
15-
16-
public static int Main(string[] args)
17-
{
18-
var tests = Layout.Create()
19-
.Add("plaintext", Content.From(Resource.FromString("Hello, World!")))
20-
.Add("fortunes", new FortuneHandlerBuilder())
21-
.AddService<JsonResource>("json")
22-
.AddService<DbResource>("db")
23-
.AddService<QueryResource>("queries")
24-
.AddService<UpdateResource>("updates")
25-
.AddService<CacheResource>("cached-worlds")
26-
.Add(ServerHeader.Create());
27-
28-
return Host.Create()
29-
.Handler(tests)
30-
.Run();
31-
}
32-
33-
}
34-
35-
}
8+
var tests = Layout.Create()
9+
.Add("plaintext", Content.From(Resource.FromString("Hello, World!")))
10+
.Add("fortunes", new FortuneHandler())
11+
.AddService<JsonResource>("json")
12+
.AddService<DbResource>("db")
13+
.AddService<QueryResource>("queries")
14+
.AddService<UpdateResource>("updates")
15+
.AddService<CacheResource>("cached-worlds")
16+
.Add(ServerHeader.Create());
17+
18+
return await Host.Create()
19+
.Handler(tests)
20+
.RunAsync();

frameworks/CSharp/genhttp/Benchmarks/Resources/Fortunes.html

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,22 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<title>@Model.Meta.Title</title>
4+
<title>Fortunes</title>
55
</head>
66
<body>
7-
@Model.Content
7+
8+
<table>
9+
<tr>
10+
<th>id</th>
11+
<th>message</th>
12+
</tr>
13+
{for cookie in cookies:
14+
<tr>
15+
<td>{ cookie.id }</td>
16+
<td>{ cookie.message }</td>
17+
</tr>
18+
}
19+
</table>
20+
821
</body>
9-
</html>
22+
</html>

0 commit comments

Comments
 (0)