Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

appMpower version 1.0 #6614

Merged
merged 3 commits into from
Jun 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 31 additions & 0 deletions frameworks/CSharp/appmpower/README.md
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"
22 changes: 22 additions & 0 deletions frameworks/CSharp/appmpower/appmpower.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
LLT21 marked this conversation as resolved.
Show resolved Hide resolved
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
LLT21 marked this conversation as resolved.
Show resolved Hide resolved

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"]
30 changes: 30 additions & 0 deletions frameworks/CSharp/appmpower/benchmark_config.json
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"
}
}
]
}
19 changes: 19 additions & 0 deletions frameworks/CSharp/appmpower/config.toml
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"
17 changes: 17 additions & 0 deletions frameworks/CSharp/appmpower/odbcinst.ini
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
8 changes: 8 additions & 0 deletions frameworks/CSharp/appmpower/src/ConnectionStrings.cs
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";
}
}
211 changes: 211 additions & 0 deletions frameworks/CSharp/appmpower/src/Db/PooledCommand.cs
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);
}
}
}