-
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.
* appMpower version 1.0 * Instantiating json serializers only once Co-authored-by: LLT21 <l.lt@fidesoft.com>
- Loading branch information
Showing
30 changed files
with
1,619 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# [appMpower](https://github.com/LLT21/)(.Net) Benchmarking Test | ||
This includes tests for plaintext, json, db, queries, updates and fortune. | ||
|
||
[`appMpower`](https://github.com/LLT21/) is a nativily compiled (AOT) .NET implementation. The native compilation is done with reflection disabled; because the most used PostgreSQL .NET library is not reflection free, the PostgreSQL ODBC driver is used instead. | ||
|
||
## Infrastructure Software Versions | ||
|
||
**Language** | ||
|
||
* C# 7.0 | ||
|
||
**Platforms** | ||
|
||
* .NET Core (Windows and Linux) | ||
|
||
**Web Servers** | ||
|
||
* [Kestrel](https://github.com/aspnet/KestrelHttpServer) | ||
|
||
**Web Stack** | ||
|
||
* ASP.NET Core | ||
|
||
## Paths & Source for Tests | ||
|
||
* [Plaintext](Benchmarks/Program.cs): "/plaintext" | ||
* [JSON Serialization](Benchmarks/Program.cs): "/json" | ||
* [Single query](Benchmarks/Program.cs): "/db" | ||
* [Multiple query](Benchmarks/Program.cs): "/queries" | ||
* [Updates](Benchmarks/Program.cs): "/updates" | ||
* [Fortune](Benchmarks/Program.cs): "/fortunes" |
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build | ||
RUN apt-get update | ||
RUN apt-get -yqq install clang zlib1g-dev libkrb5-dev libtinfo5 | ||
|
||
WORKDIR /app | ||
COPY src . | ||
RUN dotnet publish -c Release -o out -r linux-x64 | ||
|
||
FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS runtime | ||
|
||
RUN apt-get update | ||
RUN apt-get install -y unixodbc odbc-postgresql | ||
|
||
WORKDIR /etc/ | ||
COPY odbcinst.ini . | ||
|
||
WORKDIR /app | ||
COPY --from=build /app/out ./ | ||
|
||
EXPOSE 8080 | ||
|
||
ENTRYPOINT ["./appMpower"] |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"framework": "appmpower", | ||
"tests": [ | ||
{ | ||
"default": { | ||
"plaintext_url": "/plaintext", | ||
"json_url": "/json", | ||
"db_url": "/db", | ||
"query_url": "/queries?c=", | ||
"update_url": "/updates?c=", | ||
"fortune_url": "/fortunes", | ||
"port": 8080, | ||
"approach": "Realistic", | ||
"classification": "Platform", | ||
"database": "Postgres", | ||
"framework": "ASP.NET Core", | ||
"language": "C#", | ||
"orm": "Raw", | ||
"platform": ".NET", | ||
"flavor": "CoreCLR", | ||
"webserver": "Kestrel", | ||
"os": "Linux", | ||
"database_os": "Linux", | ||
"display_name": "appMpower", | ||
"notes": "", | ||
"versus": "aspcore" | ||
} | ||
} | ||
] | ||
} |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[framework] | ||
name = "appmpower" | ||
|
||
[main] | ||
urls.plaintext = "/plaintext" | ||
urls.json = "/json" | ||
urls.db = "/db" | ||
urls.query = "/queries?c=" | ||
urls.update = "/updates?c=" | ||
urls.fortune = "/fortunes" | ||
approach = "Realistic" | ||
classification = "Platform" | ||
database = "Postgres" | ||
database_os = "Linux" | ||
os = "Linux" | ||
orm = "Raw" | ||
platform = ".NET" | ||
webserver = "kestrel" | ||
versus = "aspcore" |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[ODBC] | ||
Trace=1 | ||
Debug=1 | ||
Pooling=No | ||
|
||
[ODBC Drivers] | ||
PostgreSQL = Installed | ||
|
||
; | ||
; odbcinst.ini | ||
; | ||
[PostgreSQL] | ||
Description=ODBC for PostgreSQL | ||
; WARNING: The old psql odbc driver psqlodbc.so is now renamed psqlodbcw.so | ||
; in version 08.x. Note that the library can also be installed under an other | ||
; path than /usr/local/lib/ following your installation. | ||
Driver=/usr/lib/x86_64-linux-gnu/odbc/psqlodbcw.so |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace appMpower | ||
{ | ||
public static class ConnectionStrings | ||
{ | ||
//public const string OdbcConnection = "Driver={PostgreSQL};Server=host.docker.internal;Port=5432;Database=hello_world;Uid=benchmarkdbuser;Pwd=benchmarkdbpass;UseServerSidePrepare=1;Pooling=false"; | ||
public const string OdbcConnection = "Driver={PostgreSQL};Server=tfb-database;Database=hello_world;Uid=benchmarkdbuser;Pwd=benchmarkdbpass;UseServerSidePrepare=1;Pooling=false"; | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,211 @@ | ||
using System.Data; | ||
using System.Data.Common; | ||
using System.Data.Odbc; | ||
using System.Threading.Tasks; | ||
|
||
namespace appMpower.Db | ||
{ | ||
public class PooledCommand : IDbCommand | ||
{ | ||
private OdbcCommand _odbcCommand; | ||
private PooledConnection _pooledConnection; | ||
|
||
public PooledCommand(PooledConnection pooledConnection) | ||
{ | ||
_odbcCommand = (OdbcCommand)pooledConnection.CreateCommand(); | ||
_pooledConnection = pooledConnection; | ||
} | ||
|
||
public PooledCommand(string commandText, PooledConnection pooledConnection) | ||
{ | ||
pooledConnection.GetCommand(commandText, this); | ||
} | ||
|
||
internal PooledCommand(OdbcCommand odbcCommand, PooledConnection pooledConnection) | ||
{ | ||
_odbcCommand = odbcCommand; | ||
_pooledConnection = pooledConnection; | ||
} | ||
|
||
internal OdbcCommand OdbcCommand | ||
{ | ||
get | ||
{ | ||
return _odbcCommand; | ||
} | ||
set | ||
{ | ||
_odbcCommand = value; | ||
} | ||
} | ||
|
||
internal PooledConnection PooledConnection | ||
{ | ||
get | ||
{ | ||
return _pooledConnection; | ||
} | ||
set | ||
{ | ||
_pooledConnection = value; | ||
} | ||
} | ||
|
||
public string CommandText | ||
{ | ||
get | ||
{ | ||
return _odbcCommand.CommandText; | ||
} | ||
set | ||
{ | ||
_odbcCommand.CommandText = value; | ||
} | ||
} | ||
|
||
public int CommandTimeout | ||
{ | ||
get | ||
{ | ||
return _odbcCommand.CommandTimeout; | ||
} | ||
set | ||
{ | ||
_odbcCommand.CommandTimeout = value; | ||
} | ||
} | ||
public CommandType CommandType | ||
{ | ||
get | ||
{ | ||
return _odbcCommand.CommandType; | ||
} | ||
set | ||
{ | ||
_odbcCommand.CommandType = value; | ||
} | ||
} | ||
|
||
#nullable enable | ||
public IDbConnection? Connection | ||
{ | ||
get | ||
{ | ||
return _odbcCommand.Connection; | ||
} | ||
set | ||
{ | ||
_odbcCommand.Connection = (OdbcConnection?)value; | ||
} | ||
} | ||
#nullable disable | ||
|
||
|
||
public IDataParameterCollection Parameters | ||
{ | ||
get | ||
{ | ||
return _odbcCommand.Parameters; | ||
} | ||
} | ||
|
||
#nullable enable | ||
public IDbTransaction? Transaction | ||
{ | ||
get | ||
{ | ||
return _odbcCommand.Transaction; | ||
} | ||
set | ||
{ | ||
_odbcCommand.Transaction = (OdbcTransaction?)value; | ||
} | ||
} | ||
#nullable disable | ||
|
||
public UpdateRowSource UpdatedRowSource | ||
{ | ||
get | ||
{ | ||
return _odbcCommand.UpdatedRowSource; | ||
} | ||
set | ||
{ | ||
_odbcCommand.UpdatedRowSource = value; | ||
} | ||
} | ||
public void Cancel() | ||
{ | ||
_odbcCommand.Cancel(); | ||
} | ||
|
||
public IDbDataParameter CreateParameter() | ||
{ | ||
return _odbcCommand.CreateParameter(); | ||
} | ||
|
||
public IDbDataParameter CreateParameter(string name, DbType dbType, object value) | ||
{ | ||
OdbcParameter odbcParameter = null; | ||
|
||
if (this.Parameters.Contains(name)) | ||
{ | ||
odbcParameter = (OdbcParameter)this.Parameters[name]; | ||
odbcParameter.Value = value; | ||
} | ||
else | ||
{ | ||
odbcParameter = _odbcCommand.CreateParameter(); | ||
|
||
odbcParameter.ParameterName = name; | ||
odbcParameter.DbType = dbType; | ||
odbcParameter.Value = value; | ||
this.Parameters.Add(odbcParameter); | ||
} | ||
|
||
return odbcParameter; | ||
} | ||
|
||
public int ExecuteNonQuery() | ||
{ | ||
return _odbcCommand.ExecuteNonQuery(); | ||
} | ||
|
||
public IDataReader ExecuteReader() | ||
{ | ||
return _odbcCommand.ExecuteReader(); | ||
} | ||
|
||
public async Task<int> ExecuteNonQueryAsync() | ||
{ | ||
return await _odbcCommand.ExecuteNonQueryAsync(); | ||
} | ||
|
||
public async Task<DbDataReader> ExecuteReaderAsync(CommandBehavior behavior) | ||
{ | ||
return await _odbcCommand.ExecuteReaderAsync(behavior); | ||
} | ||
|
||
public IDataReader ExecuteReader(CommandBehavior behavior) | ||
{ | ||
return _odbcCommand.ExecuteReader(behavior); | ||
} | ||
|
||
#nullable enable | ||
public object? ExecuteScalar() | ||
{ | ||
return _odbcCommand.ExecuteScalar(); | ||
} | ||
#nullable disable | ||
|
||
public void Prepare() | ||
{ | ||
_odbcCommand.Prepare(); | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
_pooledConnection.ReleaseCommand(this); | ||
} | ||
} | ||
} |
Oops, something went wrong.