Skip to content

Commit 3f2e680

Browse files
authored
Merge pull request #22 from TechEmpower/master
aa
2 parents 13fb097 + 1e1df95 commit 3f2e680

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+1024
-465
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
[Oo]bj/
2+
[Bb]in/
3+
TestResults/
4+
.nuget/
5+
*.sln.ide/
6+
_ReSharper.*/
7+
.idea/
8+
packages/
9+
artifacts/
10+
PublishProfiles/
11+
.vs/
12+
*.user
13+
*.suo
14+
*.cache
15+
*.docstates
16+
_ReSharper.*
17+
nuget.exe
18+
*net45.csproj
19+
*net451.csproj
20+
*k10.csproj
21+
*.psess
22+
*.vsp
23+
*.pidb
24+
*.userprefs
25+
*DS_Store
26+
*.ncrunchsolution
27+
*.*sdf
28+
*.ipch
29+
*.swp
30+
*~
31+
.build/
32+
.testPublish/
33+
launchSettings.json
34+
BenchmarkDotNet.Artifacts/
35+
BDN.Generated/
36+
binaries/
37+
global.json
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net6.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<NoWarn>CA2016;IDE1006</NoWarn>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="FastEndpoints" Version="2.17.0" />
12+
</ItemGroup>
13+
14+
</Project>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.0.32002.185
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Benchmarks", "Benchmarks.csproj", "{95F15ACC-FFB8-4C45-BF4E-6E2B602C1EBA}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{95F15ACC-FFB8-4C45-BF4E-6E2B602C1EBA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{95F15ACC-FFB8-4C45-BF4E-6E2B602C1EBA}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{95F15ACC-FFB8-4C45-BF4E-6E2B602C1EBA}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{95F15ACC-FFB8-4C45-BF4E-6E2B602C1EBA}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {975848F3-00CE-49FC-A82F-86DDC0A3CC6F}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
namespace Benchmarks.Endpoints;
2+
3+
public class Response
4+
{
5+
public string message => "Hello, World!";
6+
}
7+
8+
public class JsonEndpoint : Endpoint<EmptyRequest, Response>
9+
{
10+
public override void Configure()
11+
{
12+
Get("/json");
13+
AllowAnonymous();
14+
}
15+
16+
public override Task HandleAsync(EmptyRequest r, CancellationToken ct)
17+
{
18+
HttpContext.Response.ContentLength = 27;
19+
return SendAsync(Response);
20+
}
21+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
namespace Benchmarks.Endpoints;
2+
3+
public class PlainTextEndpoint : Endpoint<EmptyRequest, object>
4+
{
5+
private static readonly byte[] payload = System.Text.Encoding.UTF8.GetBytes("Hello, World!");
6+
7+
public override void Configure()
8+
{
9+
Get("/plaintext");
10+
AllowAnonymous();
11+
}
12+
13+
public override Task HandleAsync(EmptyRequest r, CancellationToken ct)
14+
{
15+
return SendBytesAsync(payload, contentType: "text/plain");
16+
}
17+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
global using FastEndpoints;
2+
3+
var builder = WebApplication.CreateBuilder();
4+
builder.Services.AddFastEndpoints();
5+
6+
var app = builder.Build();
7+
app.UseAuthorization();
8+
app.UseFastEndpoints();
9+
app.Run();
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Information",
5+
"Microsoft.AspNetCore": "Warning"
6+
}
7+
}
8+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Warning"
5+
}
6+
},
7+
"AllowedHosts": "*",
8+
"Kestrel": {
9+
"Endpoints": {
10+
"Http": {
11+
"Url": "http://*:8080"
12+
}
13+
}
14+
}
15+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# FastEndpoints Tests on Windows and Linux
2+
This includes tests for plaintext and json serialization.
3+
4+
## Infrastructure Software Versions
5+
6+
**Language**
7+
8+
* C# 10.0
9+
10+
**Platforms**
11+
12+
* .NET Core (Windows and Linux)
13+
14+
**Web Servers**
15+
16+
* [Kestrel](https://github.com/dotnet/aspnetcore/tree/main/src/Servers/Kestrel)
17+
18+
**Web Stack**
19+
20+
* [FastEndpoints](https://fast-endpoints.com/)
21+
* ASP.Net 6
22+
23+
## Paths & Source for Tests
24+
25+
* [Plaintext](Benchmarks/Endpoints/PlainTextEndpoint.cs): "http://localhost:8080/plaintext"
26+
* [JSON Serialization](Benchmarks/Endpoints/JsonEndpoint.cs): "http://localhost:8080/json"
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"framework": "fastendpoints",
3+
"tests": [
4+
{
5+
"default": {
6+
"plaintext_url": "/plaintext",
7+
"json_url": "/json",
8+
"port": 8080,
9+
"approach": "Realistic",
10+
"classification": "Micro",
11+
"database": "None",
12+
"framework": "FastEndpoints",
13+
"language": "C#",
14+
"orm": "Raw",
15+
"platform": ".NET",
16+
"flavor": "CoreCLR",
17+
"webserver": "Kestrel",
18+
"os": "Linux",
19+
"database_os": "Linux",
20+
"display_name": "FastEndpoints",
21+
"notes": "",
22+
"versus": "aspcore"
23+
}
24+
}
25+
]
26+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[framework]
2+
name = "fastendpoints"
3+
4+
[main]
5+
urls.plaintext = "/plaintext"
6+
urls.json = "/json"
7+
approach = "Realistic"
8+
classification = "Micro"
9+
database = "None"
10+
database_os = "Linux"
11+
os = "Linux"
12+
orm = "Raw"
13+
platform = ".NET"
14+
webserver = "Kestrel"
15+
versus = "aspcore"
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
2+
WORKDIR /app
3+
COPY Benchmarks .
4+
RUN dotnet publish -c Release -o out
5+
6+
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS runtime
7+
WORKDIR /app
8+
COPY --from=build /app/out ./
9+
10+
EXPOSE 8080
11+
12+
ENTRYPOINT ["dotnet", "Benchmarks.dll"]

frameworks/Dart/angel3/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.factorypath
2+
.packages
3+
.dart_tool
4+
.metals

frameworks/Dart/angel3/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ http://localhost:8080/query?queries=
4444

4545
### UPDATE
4646

47-
http://localhost:8080/update?queries=
47+
http://localhost:8080/updates?queries=
4848

4949
### FORTUNES
5050

frameworks/Dart/angel3/angel3.dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ RUN dart pub get
1818
# Set environment, start server
1919
ENV ANGEL_ENV=production
2020
EXPOSE 8080
21-
CMD dart ./run/prod.dart -p 8080 -a 0.0.0.0
21+
CMD dart ./run/prod.dart -p 8080 -a 0.0.0.0 -j 20

frameworks/Dart/angel3/orm/config/default.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ jwt_secret: INSECURE_DEFAULT_SECRET
33
host: 127.0.0.1
44
port: 8080
55
postgres:
6+
#host: localhost
67
host: tfb-database
78
port: 5432
89
database_name: hello_world
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Development-only server configuration.
2+
debug: true

frameworks/Dart/angel3/orm/lib/src/config/config.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import 'package:angel3_configuration/angel3_configuration.dart';
33
import 'package:angel3_framework/angel3_framework.dart';
44
import 'package:angel3_jael/angel3_jael.dart';
5+
import 'package:jael3/jael3.dart';
56
import 'package:file/file.dart';
67
import 'plugins/plugins.dart' as plugins;
78

@@ -16,7 +17,10 @@ AngelConfigurer configureServer(FileSystem fileSystem) {
1617
// Configure our application to render Jael templates from the `views/` directory.
1718
//
1819
// See: https://github.com/angel-dart/jael
19-
await app.configure(jael(fileSystem.directory('views'), minified: true));
20+
var viewsDirectory = fileSystem.directory('views');
21+
var viewCache = <String, Document>{};
22+
jaelTemplatePreload(viewsDirectory, viewCache);
23+
await app.configure(jael(viewsDirectory, cache: viewCache));
2024

2125
// Apply another plug-ins, i.e. ones that *you* have written.
2226
//

frameworks/Dart/angel3/orm/lib/src/config/plugins/orm.dart

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,21 @@ import 'package:angel3_framework/angel3_framework.dart';
44
import 'package:angel3_orm/angel3_orm.dart';
55
import 'package:angel3_orm_postgres/angel3_orm_postgres.dart';
66
import 'package:postgres/postgres.dart';
7+
import 'package:postgres_pool/postgres_pool.dart';
78

89
Future<void> configureServer(Angel app) async {
10+
var logger = app.environment.isProduction ? null : app.logger;
11+
912
var connection = await connectToPostgres(app.configuration);
1013
await connection.open();
11-
12-
var logger = app.environment.isProduction ? null : app.logger;
1314
var executor = PostgreSqlExecutor(connection, logger: logger);
1415

16+
//var executor = await connectToPostgresPool(app.configuration, logger);
17+
1518
app
1619
..container!.registerSingleton<QueryExecutor>(executor)
1720
..shutdownHooks.add((_) => connection.close());
21+
// ..shutdownHooks.add((_) => executor.close());
1822
}
1923

2024
Future<PostgreSQLConnection> connectToPostgres(Map configuration) async {
@@ -33,3 +37,31 @@ Future<PostgreSQLConnection> connectToPostgres(Map configuration) async {
3337
useSSL: postgresConfig['use_ssl'] as bool? ?? false);
3438
return connection;
3539
}
40+
41+
Future<PostgreSqlPoolExecutor> connectToPostgresPool(
42+
Map configuration, dynamic logger) async {
43+
var postgresConfig = configuration['postgres'] as Map? ?? {};
44+
var _pool = PgPool(
45+
PgEndpoint(
46+
host: postgresConfig['host'] as String? ?? 'localhost',
47+
port: postgresConfig['port'] as int? ?? 5432,
48+
database: postgresConfig['database_name'] as String? ??
49+
Platform.environment['USER'] ??
50+
Platform.environment['USERNAME'] ??
51+
'',
52+
username: postgresConfig['username'] as String?,
53+
password: postgresConfig['password'] as String?),
54+
settings: PgPoolSettings()
55+
..maxConnectionAge = Duration(hours: 1)
56+
..concurrency = 10,
57+
);
58+
59+
// Run sql to create the tables in a transaction
60+
//await _pool.runTx((conn) async {
61+
// for (var s in schemas) {
62+
// await conn.execute(await File('test/migrations/$s.sql').readAsString());
63+
// }
64+
//});
65+
66+
return PostgreSqlPoolExecutor(_pool, logger: logger);
67+
}

0 commit comments

Comments
 (0)