From 1c1add379c71434b7a593456a0a17313cdc23ecc Mon Sep 17 00:00:00 2001 From: Ethosa Date: Thu, 4 Jul 2024 09:17:34 +0700 Subject: [PATCH 1/9] add /Nim/happyx --- frameworks/Nim/happyx/README.md | 16 +++++++++++++ frameworks/Nim/happyx/benchmark_config.json | 26 +++++++++++++++++++++ frameworks/Nim/happyx/config.toml | 15 ++++++++++++ frameworks/Nim/happyx/happyx.dockerfile | 16 +++++++++++++ frameworks/Nim/happyx/techempower.nim | 8 +++++++ frameworks/Nim/happyx/techempower.nimble | 16 +++++++++++++ 6 files changed, 97 insertions(+) create mode 100644 frameworks/Nim/happyx/README.md create mode 100644 frameworks/Nim/happyx/benchmark_config.json create mode 100644 frameworks/Nim/happyx/config.toml create mode 100644 frameworks/Nim/happyx/happyx.dockerfile create mode 100644 frameworks/Nim/happyx/techempower.nim create mode 100644 frameworks/Nim/happyx/techempower.nimble diff --git a/frameworks/Nim/happyx/README.md b/frameworks/Nim/happyx/README.md new file mode 100644 index 00000000000..effcfc2e05f --- /dev/null +++ b/frameworks/Nim/happyx/README.md @@ -0,0 +1,16 @@ +# Nim HappyX Benchmarking Test + +## Important Libraries + +The tests were run with: + +* [HappyX](https://github.com/HapticX/happyx) + +## Test URLs +### JSON + +http://localhost:5000/json + +### PLAINTEXT + +http://localhost:5000/plaintext \ No newline at end of file diff --git a/frameworks/Nim/happyx/benchmark_config.json b/frameworks/Nim/happyx/benchmark_config.json new file mode 100644 index 00000000000..a84d9b81390 --- /dev/null +++ b/frameworks/Nim/happyx/benchmark_config.json @@ -0,0 +1,26 @@ +{ + "framework": "happyx", + "tests": [ + { + "default": { + "json_url": "/json", + "plaintext_url": "/plaintext", + "port": 5000, + "approach": "Realistic", + "classification": "Fullstack", + "database": "None", + "framework": "happyx", + "language": "Nim", + "flavor": "None", + "orm": "None", + "platform": "None", + "webserver": "None", + "os": "Linux", + "database_os": "Linux", + "display_name": "HappyX", + "notes": "", + "versus": "httpbeast, jester, prologue" + } + } + ] +} diff --git a/frameworks/Nim/happyx/config.toml b/frameworks/Nim/happyx/config.toml new file mode 100644 index 00000000000..e89931fdaf5 --- /dev/null +++ b/frameworks/Nim/happyx/config.toml @@ -0,0 +1,15 @@ +[framework] +name = "happyx" + +[main] +urls.plaintext = "/plaintext" +urls.json = "/json" +approach = "Realistic" +classification = "Fullstack" +database = "None" +database_os = "Linux" +os = "Linux" +orm = "None" +platform = "None" +webserver = "None" +versus = "httpbeast, jester, prologue" diff --git a/frameworks/Nim/happyx/happyx.dockerfile b/frameworks/Nim/happyx/happyx.dockerfile new file mode 100644 index 00000000000..7d2f82c72c3 --- /dev/null +++ b/frameworks/Nim/happyx/happyx.dockerfile @@ -0,0 +1,16 @@ +FROM ubuntu:24.04 + +RUN apt update && apt install -y libgc-dev gcc build-essential curl git + +ENV CHOOSENIM_NO_ANALYTICS 1 +ENV CHOOSENIM_CHOOSE_VERSION 2.0.8 +RUN curl https://nim-lang.org/choosenim/init.sh -sSf | sh -s -- -y +ENV PATH $PATH:/root/.nimble/bin + +ADD ./ /happyx +WORKDIR /happyx +RUN nimble c -d:danger --threads:on -y -d:disableApiDoc techempower.nim + +EXPOSE 5000 + +CMD ./techempower diff --git a/frameworks/Nim/happyx/techempower.nim b/frameworks/Nim/happyx/techempower.nim new file mode 100644 index 00000000000..bc70e147e8a --- /dev/null +++ b/frameworks/Nim/happyx/techempower.nim @@ -0,0 +1,8 @@ +import happyx + +serve "127.0.0.1", 5000: + get "/json": + return {"message": "Hello, World!"} + + get "/plaintext": + return "Hello, World!" diff --git a/frameworks/Nim/happyx/techempower.nimble b/frameworks/Nim/happyx/techempower.nimble new file mode 100644 index 00000000000..f12b0b32cba --- /dev/null +++ b/frameworks/Nim/happyx/techempower.nimble @@ -0,0 +1,16 @@ +# Package + +version = "0.1.0" +author = "Ethosa" +description = "TechEmpower HappyX benchmark." +license = "MIT" + +bin = @["techempower"] +skipExt = @["nim"] + +# Dependencies + +requires "nim >= 1.0.0" + +# We lock dependencies here on purpose. +requires "happyx#head" From 5aadcd2b4f74e74e275c86d9ee09f379303396cc Mon Sep 17 00:00:00 2001 From: Ethosa Date: Thu, 4 Jul 2024 09:21:09 +0700 Subject: [PATCH 2/9] change dockerfile --- frameworks/Nim/happyx/happyx.dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/Nim/happyx/happyx.dockerfile b/frameworks/Nim/happyx/happyx.dockerfile index 7d2f82c72c3..65e0952e073 100644 --- a/frameworks/Nim/happyx/happyx.dockerfile +++ b/frameworks/Nim/happyx/happyx.dockerfile @@ -9,7 +9,7 @@ ENV PATH $PATH:/root/.nimble/bin ADD ./ /happyx WORKDIR /happyx -RUN nimble c -d:danger --threads:on -y -d:disableApiDoc techempower.nim +RUN nimble c -d:danger -d:httpbeast --threads:on -y -d:disableApiDoc techempower.nim EXPOSE 5000 From f1c1a74be0e4464b333f6bcd106d323960426ccb Mon Sep 17 00:00:00 2001 From: Ethosa Date: Thu, 4 Jul 2024 09:22:08 +0700 Subject: [PATCH 3/9] add /Nim/happyx --- frameworks/Nim/happyx/happyx.dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/Nim/happyx/happyx.dockerfile b/frameworks/Nim/happyx/happyx.dockerfile index 65e0952e073..b87a0c84bfe 100644 --- a/frameworks/Nim/happyx/happyx.dockerfile +++ b/frameworks/Nim/happyx/happyx.dockerfile @@ -9,7 +9,7 @@ ENV PATH $PATH:/root/.nimble/bin ADD ./ /happyx WORKDIR /happyx -RUN nimble c -d:danger -d:httpbeast --threads:on -y -d:disableApiDoc techempower.nim +RUN nimble c -d:danger -d:beast --threads:on -y -d:disableApiDoc techempower.nim EXPOSE 5000 From 56b4e9d6525837d470e1b67a2e3e7b8900d435ac Mon Sep 17 00:00:00 2001 From: Ethosa Date: Mon, 8 Jul 2024 23:00:18 +0700 Subject: [PATCH 4/9] update im/happyx dockerfile --- frameworks/Nim/happyx/happyx.dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frameworks/Nim/happyx/happyx.dockerfile b/frameworks/Nim/happyx/happyx.dockerfile index b87a0c84bfe..c64be6d6012 100644 --- a/frameworks/Nim/happyx/happyx.dockerfile +++ b/frameworks/Nim/happyx/happyx.dockerfile @@ -9,7 +9,8 @@ ENV PATH $PATH:/root/.nimble/bin ADD ./ /happyx WORKDIR /happyx -RUN nimble c -d:danger -d:beast --threads:on -y -d:disableApiDoc techempower.nim +RUN nimble install happyx@#head +RUN nim c -d:danger -d:beast --threads:on -y -d:disableApiDoc techempower.nim EXPOSE 5000 From eef7958e12d24275aec2c748a3a1d6a10bdec1fc Mon Sep 17 00:00:00 2001 From: Ethosa Date: Tue, 9 Jul 2024 00:05:04 +0700 Subject: [PATCH 5/9] fix nim/happyx dockerfile --- frameworks/Nim/happyx/happyx.dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/Nim/happyx/happyx.dockerfile b/frameworks/Nim/happyx/happyx.dockerfile index c64be6d6012..baad0cac1bd 100644 --- a/frameworks/Nim/happyx/happyx.dockerfile +++ b/frameworks/Nim/happyx/happyx.dockerfile @@ -10,7 +10,7 @@ ENV PATH $PATH:/root/.nimble/bin ADD ./ /happyx WORKDIR /happyx RUN nimble install happyx@#head -RUN nim c -d:danger -d:beast --threads:on -y -d:disableApiDoc techempower.nim +RUN nim c -d:danger -d:beast --threads:on -d:disableApiDoc techempower.nim EXPOSE 5000 From be75997b81bdcea13744c9f6ddbc8c11742ee38d Mon Sep 17 00:00:00 2001 From: Ethosa Date: Tue, 9 Jul 2024 08:16:28 +0700 Subject: [PATCH 6/9] change nim/happyx host to 0.0.0.0 --- frameworks/Nim/happyx/techempower.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/Nim/happyx/techempower.nim b/frameworks/Nim/happyx/techempower.nim index bc70e147e8a..43b3b4a71e4 100644 --- a/frameworks/Nim/happyx/techempower.nim +++ b/frameworks/Nim/happyx/techempower.nim @@ -1,6 +1,6 @@ import happyx -serve "127.0.0.1", 5000: +serve "0.0.0.0", 5000: get "/json": return {"message": "Hello, World!"} From d2d0aa4b7c8fd4cf60ac9312a54ba861572a4ccb Mon Sep 17 00:00:00 2001 From: Ethosa Date: Wed, 10 Jul 2024 01:11:23 +0700 Subject: [PATCH 7/9] update nim/happyx config, fix framework --- frameworks/Nim/happyx/benchmark_config.json | 2 +- frameworks/Nim/happyx/config.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frameworks/Nim/happyx/benchmark_config.json b/frameworks/Nim/happyx/benchmark_config.json index a84d9b81390..1213bf66a8d 100644 --- a/frameworks/Nim/happyx/benchmark_config.json +++ b/frameworks/Nim/happyx/benchmark_config.json @@ -19,7 +19,7 @@ "database_os": "Linux", "display_name": "HappyX", "notes": "", - "versus": "httpbeast, jester, prologue" + "versus": "httpbeast, jester, prologue, basolato" } } ] diff --git a/frameworks/Nim/happyx/config.toml b/frameworks/Nim/happyx/config.toml index e89931fdaf5..a4fa99f4610 100644 --- a/frameworks/Nim/happyx/config.toml +++ b/frameworks/Nim/happyx/config.toml @@ -12,4 +12,4 @@ os = "Linux" orm = "None" platform = "None" webserver = "None" -versus = "httpbeast, jester, prologue" +versus = "httpbeast, jester, prologue, basolato" From 11b3bf30bf034be0903d1e959d617b095ba446fd Mon Sep 17 00:00:00 2001 From: Ethosa Date: Mon, 15 Jul 2024 17:54:25 +0700 Subject: [PATCH 8/9] add Nim/README.md --- frameworks/Nim/README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 frameworks/Nim/README.md diff --git a/frameworks/Nim/README.md b/frameworks/Nim/README.md new file mode 100644 index 00000000000..397cd0f6eef --- /dev/null +++ b/frameworks/Nim/README.md @@ -0,0 +1,14 @@ +# Nim frameworks + +The information below contains information specific to Nim. +For further guidance, review the +[documentation](https://github.com/TechEmpower/FrameworkBenchmarks/wiki). + +## Get Help + +### [Nim Community](https://nim-lang.org/community.html) + +* [`nim_lang` telegram chat](https://t.me/nim_lang) +* [nim forum](https://forum.nim-lang.org/) +* [`Discord/Nim`](https://discord.gg/nim) +* [`IRC Logs`](https://irclogs.nim-lang.org/) From f5ab710325ff590728d93af3f46d4af794975f9e Mon Sep 17 00:00:00 2001 From: Ethosa Date: Mon, 15 Jul 2024 18:36:55 +0700 Subject: [PATCH 9/9] add /db test --- frameworks/Nim/happyx/benchmark_config.json | 5 ++-- frameworks/Nim/happyx/config.toml | 5 ++-- frameworks/Nim/happyx/happyx.dockerfile | 5 ++++ frameworks/Nim/happyx/techempower.nim | 29 ++++++++++++++++++++- frameworks/Nim/happyx/techempower.nimble | 1 + 5 files changed, 40 insertions(+), 5 deletions(-) diff --git a/frameworks/Nim/happyx/benchmark_config.json b/frameworks/Nim/happyx/benchmark_config.json index 1213bf66a8d..20e4bde48db 100644 --- a/frameworks/Nim/happyx/benchmark_config.json +++ b/frameworks/Nim/happyx/benchmark_config.json @@ -5,14 +5,15 @@ "default": { "json_url": "/json", "plaintext_url": "/plaintext", + "db_url": "/db", "port": 5000, "approach": "Realistic", "classification": "Fullstack", - "database": "None", + "database": "postgres", "framework": "happyx", "language": "Nim", "flavor": "None", - "orm": "None", + "orm": "Full", "platform": "None", "webserver": "None", "os": "Linux", diff --git a/frameworks/Nim/happyx/config.toml b/frameworks/Nim/happyx/config.toml index a4fa99f4610..387fb6e7c93 100644 --- a/frameworks/Nim/happyx/config.toml +++ b/frameworks/Nim/happyx/config.toml @@ -4,12 +4,13 @@ name = "happyx" [main] urls.plaintext = "/plaintext" urls.json = "/json" +urls.db = "/db" approach = "Realistic" classification = "Fullstack" -database = "None" +database = "postgres" database_os = "Linux" os = "Linux" -orm = "None" +orm = "Full" platform = "None" webserver = "None" versus = "httpbeast, jester, prologue, basolato" diff --git a/frameworks/Nim/happyx/happyx.dockerfile b/frameworks/Nim/happyx/happyx.dockerfile index baad0cac1bd..c92a005af47 100644 --- a/frameworks/Nim/happyx/happyx.dockerfile +++ b/frameworks/Nim/happyx/happyx.dockerfile @@ -6,10 +6,15 @@ ENV CHOOSENIM_NO_ANALYTICS 1 ENV CHOOSENIM_CHOOSE_VERSION 2.0.8 RUN curl https://nim-lang.org/choosenim/init.sh -sSf | sh -s -- -y ENV PATH $PATH:/root/.nimble/bin +ENV DB_DATABASE="hello_world" +ENV DB_USER="benchmarkdbuser" +ENV DB_PASSWORD="benchmarkdbpass" +ENV DB_HOST="tfb-database" ADD ./ /happyx WORKDIR /happyx RUN nimble install happyx@#head +RUN nimble install norm RUN nim c -d:danger -d:beast --threads:on -d:disableApiDoc techempower.nim EXPOSE 5000 diff --git a/frameworks/Nim/happyx/techempower.nim b/frameworks/Nim/happyx/techempower.nim index 43b3b4a71e4..66d1b8a662c 100644 --- a/frameworks/Nim/happyx/techempower.nim +++ b/frameworks/Nim/happyx/techempower.nim @@ -1,8 +1,35 @@ -import happyx +import + std/[os, random], + happyx, + norm/[model, postgres] + + +type + World* = ref object of Model + + +const + dbHost = getEnv("DB_HOST", "127.0.0.1") + dbUser = getEnv("DB_USER", "root") + dbPassword = getEnv("DB_PASSWORD", "123456") + dbDatabase = getEnv("DB_DATABASE", "hello_world") + + +randomize() + serve "0.0.0.0", 5000: + setup: + let dbConn = open(dbHost, dbUser, dbPassword, dbDatabase) + get "/json": return {"message": "Hello, World!"} get "/plaintext": return "Hello, World!" + + get "/db": + let rowId = rand(1..10_000) + var row = World(id: 0) + dbConn.select(row, "id = $1", rowId.int64) + return {"id": row.id, "randomNumber": rowId} diff --git a/frameworks/Nim/happyx/techempower.nimble b/frameworks/Nim/happyx/techempower.nimble index f12b0b32cba..2ceecec3471 100644 --- a/frameworks/Nim/happyx/techempower.nimble +++ b/frameworks/Nim/happyx/techempower.nimble @@ -14,3 +14,4 @@ requires "nim >= 1.0.0" # We lock dependencies here on purpose. requires "happyx#head" +requires "norm"