Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jaguililla committed Dec 23, 2024
2 parents 97f4f7d + 6d5e760 commit f236c8b
Show file tree
Hide file tree
Showing 420 changed files with 6,020 additions and 2,991 deletions.
15 changes: 15 additions & 0 deletions frameworks/C++/poco/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# POCO C++ Libraries Benchmarking Test

- [POCO Github Repository](https://github.com/pocoproject/poco)
- [POCO Website](https://pocoproject.org/)

## Software Versions

- [buildpack-deps noble](https://hub.docker.com/_/buildpack-deps)
- [g++ 14](https://gcc.gnu.org/gcc-14/)
- [c++17](https://en.cppreference.com/w/cpp/17)
- [POCO 1.13.1](https://pocoproject.org/releases/poco-1.13.1/poco-1.13.1-all.zip)

## Test URLs

- `PLAINTEXT` - [http://127.0.0.1:8080/plaintext](http://127.0.0.1:8080/plaintext)
11 changes: 10 additions & 1 deletion frameworks/C++/poco/benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include <Poco/Net/HTTPServerRequest.h>
#include <Poco/Net/HTTPServerResponse.h>
#include <Poco/Util/ServerApplication.h>
#include <Poco/Timespan.h>
#include <Poco/Thread.h>

#include <iostream>
#include <string>
Expand All @@ -15,7 +17,9 @@
#define PLAIN_CONTENT_TYPE "text/plain"
#define RES_BODY "Hello, World!"
#define SERVER_NAME "poco"
#define MAX_CONNECTIONS 16384

using namespace Poco;
using namespace Poco::Net;
using namespace Poco::Util;
using namespace std;
Expand Down Expand Up @@ -58,7 +62,12 @@ class MyServerApp : public ServerApplication {
HTTPServerParams* hsp = new HTTPServerParams;
hsp->setMaxThreads(stoi(args[1]));
hsp->setKeepAlive(true);
HTTPServer s(new MyRequestHandlerFactory, ServerSocket(stoi(args[0]), 4000), hsp);
hsp->setMaxKeepAliveRequests(MAX_CONNECTIONS);
hsp->setMaxQueued(MAX_CONNECTIONS);
hsp->setThreadPriority(Thread::PRIO_HIGHEST);
ServerSocket socket(stoi(args[0]), MAX_CONNECTIONS);
socket.setBlocking(false);
HTTPServer s(new MyRequestHandlerFactory, socket, hsp);
s.start();
waitForTerminationRequest();
s.stop();
Expand Down
12 changes: 6 additions & 6 deletions frameworks/C++/poco/poco.dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
FROM buildpack-deps:xenial
FROM buildpack-deps:noble

RUN apt-get update -yqq && apt-get install -yqq software-properties-common unzip cmake

RUN apt-get install -yqq g++-4.8 libjson0-dev
RUN update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 50
RUN apt-get install -yqq g++-14
RUN update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-14 50

ENV POCO_VERSION 1.6.1
ENV POCO_VERSION 1.13.3
ENV POCO_HOME /poco

WORKDIR ${POCO_HOME}
Expand All @@ -20,10 +20,10 @@ ENV LD_LIBRARY_PATH ${POCO_HOME}/lib/Linux/x86_64

COPY benchmark.cpp benchmark.cpp

RUN g++-4.8 \
RUN g++-14 \
-O3 \
-DNDEBUG \
-std=c++0x \
-std=c++17 \
-o \
poco \
benchmark.cpp \
Expand Down
8 changes: 5 additions & 3 deletions frameworks/CSharp/appmpower/appmpower-odbc-my.dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/sdk:8.0.100 AS build
FROM mcr.microsoft.com/dotnet/sdk:9.0.100 AS build
RUN apt-get update
RUN apt-get -yqq install clang zlib1g-dev
RUN apt-get update
Expand All @@ -8,12 +8,12 @@ COPY src .
RUN dotnet publish -c Release -o out /p:Database=mysql

# Construct the actual image that will run
FROM mcr.microsoft.com/dotnet/aspnet:8.0.0 AS runtime
FROM mcr.microsoft.com/dotnet/aspnet:9.0.0 AS runtime

RUN apt-get update
# The following installs standard versions unixodbc and pgsqlodbc
# unixodbc still needs to be installed even if compiled locally
RUN apt-get install -y unixodbc wget curl
RUN apt-get install -y unixodbc-dev unixodbc wget curl
RUN apt-get update

WORKDIR /odbc
Expand Down Expand Up @@ -45,6 +45,8 @@ WORKDIR /app
COPY --from=build /app/out ./

RUN cp /usr/lib/libm* /app
#RUN cp /usr/lib/aarch64-linux-gnu/libodbc* /app
RUN cp /usr/lib/x86_64-linux-gnu/libodbc* /app

EXPOSE 8080

Expand Down
10 changes: 7 additions & 3 deletions frameworks/CSharp/appmpower/appmpower-odbc-pg.dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/sdk:8.0.100 AS build
FROM mcr.microsoft.com/dotnet/sdk:9.0.100 AS build
RUN apt-get update
RUN apt-get -yqq install clang zlib1g-dev libkrb5-dev libtinfo5

Expand All @@ -7,10 +7,10 @@ COPY src .
RUN dotnet publish -c Release -o out /p:Database=postgresql

# Construct the actual image that will run
FROM mcr.microsoft.com/dotnet/aspnet:8.0.0 AS runtime
FROM mcr.microsoft.com/dotnet/aspnet:9.0.0 AS runtime

RUN apt-get update
RUN apt-get install -y unixodbc odbc-postgresql
RUN apt-get install -y unixodbc-dev unixodbc odbc-postgresql
# unixodbc still needs to be installed even if compiled locally

ENV PATH=/usr/local/unixODBC/bin:$PATH
Expand All @@ -27,6 +27,10 @@ ENV ASPNETCORE_URLS http://+:8080
WORKDIR /app
COPY --from=build /app/out ./

#RUN cp /usr/lib/aarch64-linux-gnu/libodbc* /app
RUN cp /usr/lib/x86_64-linux-gnu/libodbc* /app


EXPOSE 8080

ENTRYPOINT ["./appMpower"]
4 changes: 2 additions & 2 deletions frameworks/CSharp/appmpower/appmpower.dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/sdk:8.0.100 AS build
FROM mcr.microsoft.com/dotnet/sdk:9.0.100 AS build
RUN apt-get update
RUN apt-get -yqq install clang zlib1g-dev libkrb5-dev libtinfo5

Expand All @@ -8,7 +8,7 @@ COPY src .
RUN dotnet publish -c Release -o out

# Construct the actual image that will run
FROM mcr.microsoft.com/dotnet/aspnet:8.0.0 AS runtime
FROM mcr.microsoft.com/dotnet/aspnet:9.0.0 AS runtime
# Full PGO
ENV DOTNET_TieredPGO 1
ENV DOTNET_TC_QuickJitForLoops 1
Expand Down
59 changes: 59 additions & 0 deletions frameworks/CSharp/appmpower/src/appMpower.Orm/NativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ public static class NativeMethods

private readonly static WorldSerializer _worldSerializer = new WorldSerializer();
private readonly static WorldsSerializer _worldsSerializer = new WorldsSerializer();
private readonly static FortunesSerializer _fortunesSerializer = new FortunesSerializer();
private static readonly byte[] _delimiter = new byte[] { 0xFF, 0xFF, 0xFF, 0xFF };


[UnmanagedCallersOnly(EntryPoint = "Dbms")]
public static void Dbms(int dbms)
Expand Down Expand Up @@ -66,6 +69,7 @@ public static unsafe IntPtr Db(int* length, IntPtr* handlePointer)
*/
}

/*
[UnmanagedCallersOnly(EntryPoint = "Fortunes")]
public static unsafe IntPtr Fortunes(int* length, IntPtr* handlePointer)
{
Expand All @@ -81,6 +85,61 @@ public static unsafe IntPtr Fortunes(int* length, IntPtr* handlePointer)
return byteArrayPointer;
}
*/

[UnmanagedCallersOnly(EntryPoint = "Fortunes")]
public static unsafe IntPtr Fortunes(int* length, IntPtr* handlePointer)
{
List<Fortune> fortunes = RawDb.LoadFortunesRows().GetAwaiter().GetResult();

int totalSize = 0;

foreach (var fortune in fortunes)
{
totalSize += sizeof(int) // for Id
+ Encoding.UTF8.GetByteCount(fortune.Message ?? "") // for Message
+ _delimiter.Length; // for delimiter
}

// Allocate the total buffer
byte[] buffer = new byte[totalSize];
int offset = 0;

// Write each object to the buffer
foreach (var fortune in fortunes)
{
// Write Id
BitConverter.TryWriteBytes(buffer.AsSpan(offset, sizeof(int)), fortune.Id);
offset += sizeof(int);

// Write Message
int descriptionLength = Encoding.UTF8.GetBytes(fortune.Message ?? "", buffer.AsSpan(offset));
offset += descriptionLength;

// Write Delimiter
_delimiter.CopyTo(buffer, offset);
offset += _delimiter.Length;
}

byte[] byteArray = buffer.ToArray();
*length = byteArray.Length;

/*
var memoryStream = new MemoryStream();
using var utf8JsonWriter = new Utf8JsonWriter(memoryStream, _jsonWriterOptions);
_fortunesSerializer.Serialize(utf8JsonWriter, fortunes);
byte[] byteArray = memoryStream.ToArray();
*length = (int)utf8JsonWriter.BytesCommitted;
*/

GCHandle handle = GCHandle.Alloc(byteArray, GCHandleType.Pinned);
IntPtr byteArrayPointer = handle.AddrOfPinnedObject();
*handlePointer = GCHandle.ToIntPtr(handle);

return byteArrayPointer;
}

[UnmanagedCallersOnly(EntryPoint = "Query")]
public static unsafe IntPtr Query(int queries, int* length, IntPtr* handlePointer)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System.Text.Json;
using appMpower.Orm.Objects;

namespace appMpower.Orm.Serializers
{
public class FortunesSerializer : IJsonSerializer<List<Fortune>>
{
public void Serialize(Utf8JsonWriter utf8JsonWriter, List<Fortune> fortunes)
{
utf8JsonWriter.WriteStartArray();

foreach (Fortune fortune in fortunes)
{
utf8JsonWriter.WriteStartObject();
utf8JsonWriter.WriteNumber("id", fortune.Id);
utf8JsonWriter.WriteString("message", fortune.Message);
utf8JsonWriter.WriteEndObject();
}

utf8JsonWriter.WriteEndArray();
utf8JsonWriter.Flush();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>

<PublishAot>true</PublishAot>
Expand Down Expand Up @@ -36,7 +36,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.Data.Odbc" Version="8.0.0" />
<PackageReference Include="System.Data.Odbc" Version="9.0.0" />
</ItemGroup>

</Project>
Loading

0 comments on commit f236c8b

Please sign in to comment.