Skip to content

Commit f236c8b

Browse files
committed
2 parents 97f4f7d + 6d5e760 commit f236c8b

File tree

420 files changed

+6020
-2991
lines changed

Some content is hidden

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

420 files changed

+6020
-2991
lines changed

frameworks/C++/poco/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# POCO C++ Libraries Benchmarking Test
2+
3+
- [POCO Github Repository](https://github.com/pocoproject/poco)
4+
- [POCO Website](https://pocoproject.org/)
5+
6+
## Software Versions
7+
8+
- [buildpack-deps noble](https://hub.docker.com/_/buildpack-deps)
9+
- [g++ 14](https://gcc.gnu.org/gcc-14/)
10+
- [c++17](https://en.cppreference.com/w/cpp/17)
11+
- [POCO 1.13.1](https://pocoproject.org/releases/poco-1.13.1/poco-1.13.1-all.zip)
12+
13+
## Test URLs
14+
15+
- `PLAINTEXT` - [http://127.0.0.1:8080/plaintext](http://127.0.0.1:8080/plaintext)

frameworks/C++/poco/benchmark.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#include <Poco/Net/HTTPServerRequest.h>
77
#include <Poco/Net/HTTPServerResponse.h>
88
#include <Poco/Util/ServerApplication.h>
9+
#include <Poco/Timespan.h>
10+
#include <Poco/Thread.h>
911

1012
#include <iostream>
1113
#include <string>
@@ -15,7 +17,9 @@
1517
#define PLAIN_CONTENT_TYPE "text/plain"
1618
#define RES_BODY "Hello, World!"
1719
#define SERVER_NAME "poco"
20+
#define MAX_CONNECTIONS 16384
1821

22+
using namespace Poco;
1923
using namespace Poco::Net;
2024
using namespace Poco::Util;
2125
using namespace std;
@@ -58,7 +62,12 @@ class MyServerApp : public ServerApplication {
5862
HTTPServerParams* hsp = new HTTPServerParams;
5963
hsp->setMaxThreads(stoi(args[1]));
6064
hsp->setKeepAlive(true);
61-
HTTPServer s(new MyRequestHandlerFactory, ServerSocket(stoi(args[0]), 4000), hsp);
65+
hsp->setMaxKeepAliveRequests(MAX_CONNECTIONS);
66+
hsp->setMaxQueued(MAX_CONNECTIONS);
67+
hsp->setThreadPriority(Thread::PRIO_HIGHEST);
68+
ServerSocket socket(stoi(args[0]), MAX_CONNECTIONS);
69+
socket.setBlocking(false);
70+
HTTPServer s(new MyRequestHandlerFactory, socket, hsp);
6271
s.start();
6372
waitForTerminationRequest();
6473
s.stop();

frameworks/C++/poco/poco.dockerfile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
FROM buildpack-deps:xenial
1+
FROM buildpack-deps:noble
22

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

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

8-
ENV POCO_VERSION 1.6.1
8+
ENV POCO_VERSION 1.13.3
99
ENV POCO_HOME /poco
1010

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

2121
COPY benchmark.cpp benchmark.cpp
2222

23-
RUN g++-4.8 \
23+
RUN g++-14 \
2424
-O3 \
2525
-DNDEBUG \
26-
-std=c++0x \
26+
-std=c++17 \
2727
-o \
2828
poco \
2929
benchmark.cpp \

frameworks/CSharp/appmpower/appmpower-odbc-my.dockerfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM mcr.microsoft.com/dotnet/sdk:8.0.100 AS build
1+
FROM mcr.microsoft.com/dotnet/sdk:9.0.100 AS build
22
RUN apt-get update
33
RUN apt-get -yqq install clang zlib1g-dev
44
RUN apt-get update
@@ -8,12 +8,12 @@ COPY src .
88
RUN dotnet publish -c Release -o out /p:Database=mysql
99

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

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

1919
WORKDIR /odbc
@@ -45,6 +45,8 @@ WORKDIR /app
4545
COPY --from=build /app/out ./
4646

4747
RUN cp /usr/lib/libm* /app
48+
#RUN cp /usr/lib/aarch64-linux-gnu/libodbc* /app
49+
RUN cp /usr/lib/x86_64-linux-gnu/libodbc* /app
4850

4951
EXPOSE 8080
5052

frameworks/CSharp/appmpower/appmpower-odbc-pg.dockerfile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM mcr.microsoft.com/dotnet/sdk:8.0.100 AS build
1+
FROM mcr.microsoft.com/dotnet/sdk:9.0.100 AS build
22
RUN apt-get update
33
RUN apt-get -yqq install clang zlib1g-dev libkrb5-dev libtinfo5
44

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

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

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

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

30+
#RUN cp /usr/lib/aarch64-linux-gnu/libodbc* /app
31+
RUN cp /usr/lib/x86_64-linux-gnu/libodbc* /app
32+
33+
3034
EXPOSE 8080
3135

3236
ENTRYPOINT ["./appMpower"]

frameworks/CSharp/appmpower/appmpower.dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM mcr.microsoft.com/dotnet/sdk:8.0.100 AS build
1+
FROM mcr.microsoft.com/dotnet/sdk:9.0.100 AS build
22
RUN apt-get update
33
RUN apt-get -yqq install clang zlib1g-dev libkrb5-dev libtinfo5
44

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

1010
# Construct the actual image that will run
11-
FROM mcr.microsoft.com/dotnet/aspnet:8.0.0 AS runtime
11+
FROM mcr.microsoft.com/dotnet/aspnet:9.0.0 AS runtime
1212
# Full PGO
1313
ENV DOTNET_TieredPGO 1
1414
ENV DOTNET_TC_QuickJitForLoops 1

frameworks/CSharp/appmpower/src/appMpower.Orm/NativeMethods.cs

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ public static class NativeMethods
1717

1818
private readonly static WorldSerializer _worldSerializer = new WorldSerializer();
1919
private readonly static WorldsSerializer _worldsSerializer = new WorldsSerializer();
20+
private readonly static FortunesSerializer _fortunesSerializer = new FortunesSerializer();
21+
private static readonly byte[] _delimiter = new byte[] { 0xFF, 0xFF, 0xFF, 0xFF };
22+
2023

2124
[UnmanagedCallersOnly(EntryPoint = "Dbms")]
2225
public static void Dbms(int dbms)
@@ -66,6 +69,7 @@ public static unsafe IntPtr Db(int* length, IntPtr* handlePointer)
6669
*/
6770
}
6871

72+
/*
6973
[UnmanagedCallersOnly(EntryPoint = "Fortunes")]
7074
public static unsafe IntPtr Fortunes(int* length, IntPtr* handlePointer)
7175
{
@@ -81,6 +85,61 @@ public static unsafe IntPtr Fortunes(int* length, IntPtr* handlePointer)
8185
8286
return byteArrayPointer;
8387
}
88+
*/
89+
90+
[UnmanagedCallersOnly(EntryPoint = "Fortunes")]
91+
public static unsafe IntPtr Fortunes(int* length, IntPtr* handlePointer)
92+
{
93+
List<Fortune> fortunes = RawDb.LoadFortunesRows().GetAwaiter().GetResult();
94+
95+
int totalSize = 0;
96+
97+
foreach (var fortune in fortunes)
98+
{
99+
totalSize += sizeof(int) // for Id
100+
+ Encoding.UTF8.GetByteCount(fortune.Message ?? "") // for Message
101+
+ _delimiter.Length; // for delimiter
102+
}
103+
104+
// Allocate the total buffer
105+
byte[] buffer = new byte[totalSize];
106+
int offset = 0;
107+
108+
// Write each object to the buffer
109+
foreach (var fortune in fortunes)
110+
{
111+
// Write Id
112+
BitConverter.TryWriteBytes(buffer.AsSpan(offset, sizeof(int)), fortune.Id);
113+
offset += sizeof(int);
114+
115+
// Write Message
116+
int descriptionLength = Encoding.UTF8.GetBytes(fortune.Message ?? "", buffer.AsSpan(offset));
117+
offset += descriptionLength;
118+
119+
// Write Delimiter
120+
_delimiter.CopyTo(buffer, offset);
121+
offset += _delimiter.Length;
122+
}
123+
124+
byte[] byteArray = buffer.ToArray();
125+
*length = byteArray.Length;
126+
127+
/*
128+
var memoryStream = new MemoryStream();
129+
using var utf8JsonWriter = new Utf8JsonWriter(memoryStream, _jsonWriterOptions);
130+
131+
_fortunesSerializer.Serialize(utf8JsonWriter, fortunes);
132+
133+
byte[] byteArray = memoryStream.ToArray();
134+
*length = (int)utf8JsonWriter.BytesCommitted;
135+
*/
136+
137+
GCHandle handle = GCHandle.Alloc(byteArray, GCHandleType.Pinned);
138+
IntPtr byteArrayPointer = handle.AddrOfPinnedObject();
139+
*handlePointer = GCHandle.ToIntPtr(handle);
140+
141+
return byteArrayPointer;
142+
}
84143

85144
[UnmanagedCallersOnly(EntryPoint = "Query")]
86145
public static unsafe IntPtr Query(int queries, int* length, IntPtr* handlePointer)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using System.Text.Json;
2+
using appMpower.Orm.Objects;
3+
4+
namespace appMpower.Orm.Serializers
5+
{
6+
public class FortunesSerializer : IJsonSerializer<List<Fortune>>
7+
{
8+
public void Serialize(Utf8JsonWriter utf8JsonWriter, List<Fortune> fortunes)
9+
{
10+
utf8JsonWriter.WriteStartArray();
11+
12+
foreach (Fortune fortune in fortunes)
13+
{
14+
utf8JsonWriter.WriteStartObject();
15+
utf8JsonWriter.WriteNumber("id", fortune.Id);
16+
utf8JsonWriter.WriteString("message", fortune.Message);
17+
utf8JsonWriter.WriteEndObject();
18+
}
19+
20+
utf8JsonWriter.WriteEndArray();
21+
utf8JsonWriter.Flush();
22+
}
23+
}
24+
}

frameworks/CSharp/appmpower/src/appMpower.Orm/appMpower.Orm.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFramework>net9.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66

77
<PublishAot>true</PublishAot>
@@ -36,7 +36,7 @@
3636
</PropertyGroup>
3737

3838
<ItemGroup>
39-
<PackageReference Include="System.Data.Odbc" Version="8.0.0" />
39+
<PackageReference Include="System.Data.Odbc" Version="9.0.0" />
4040
</ItemGroup>
4141

4242
</Project>

0 commit comments

Comments
 (0)