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

[Nim|HappyX] New framework #9144

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions frameworks/Nim/README.md
Original file line number Diff line number Diff line change
@@ -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/)
16 changes: 16 additions & 0 deletions frameworks/Nim/happyx/README.md
Original file line number Diff line number Diff line change
@@ -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
27 changes: 27 additions & 0 deletions frameworks/Nim/happyx/benchmark_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"framework": "happyx",
"tests": [
{
"default": {
"json_url": "/json",
"plaintext_url": "/plaintext",
"db_url": "/db",
"port": 5000,
"approach": "Realistic",
"classification": "Fullstack",
"database": "postgres",
"framework": "happyx",
"language": "Nim",
"flavor": "None",
"orm": "Full",
"platform": "None",
"webserver": "None",
"os": "Linux",
"database_os": "Linux",
"display_name": "HappyX",
"notes": "",
"versus": "httpbeast, jester, prologue, basolato"
}
}
]
}
16 changes: 16 additions & 0 deletions frameworks/Nim/happyx/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[framework]
name = "happyx"

[main]
urls.plaintext = "/plaintext"
urls.json = "/json"
urls.db = "/db"
approach = "Realistic"
classification = "Fullstack"
database = "postgres"
database_os = "Linux"
os = "Linux"
orm = "Full"
platform = "None"
webserver = "None"
versus = "httpbeast, jester, prologue, basolato"
22 changes: 22 additions & 0 deletions frameworks/Nim/happyx/happyx.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
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
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

CMD ./techempower
35 changes: 35 additions & 0 deletions frameworks/Nim/happyx/techempower.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
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}
17 changes: 17 additions & 0 deletions frameworks/Nim/happyx/techempower.nimble
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# 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"
requires "norm"
Loading