Skip to content
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
18 changes: 18 additions & 0 deletions frameworks/Clojure/kit/benchmark_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,24 @@
"display_name": "kit-majavat",
"notes": "",
"versus": "kit"
},
"hiccup": {
"fortune_url": "/hiccup-fortunes",
"port": 8080,
"approach": "Realistic",
"classification": "Platform",
"database": "postgres",
"framework": "None",
"language": "Clojure",
"flavor": "None",
"orm": "Raw",
"platform": "None",
"webserver": "None",
"os": "Linux",
"database_os": "Linux",
"display_name": "kit-hiccup",
"notes": "",
"versus": "kit"
}
}
]
Expand Down
1 change: 1 addition & 0 deletions frameworks/Clojure/kit/deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
;; HTML templating
selmer/selmer {:mvn/version "1.12.62"}
org.clojars.jj/majavat {:mvn/version "1.12.3"}
hiccup/hiccup {:mvn/version "2.0.0"}

;; Database
org.postgresql/postgresql {:mvn/version "42.7.8"}
Expand Down
19 changes: 19 additions & 0 deletions frameworks/Clojure/kit/kit-hiccup.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# syntax = docker/dockerfile:1.2
FROM clojure:openjdk-17 AS build

WORKDIR /
COPY . /

RUN clj -Sforce -T:build all

FROM amazoncorretto:25

COPY --from=build /target/te-bench-standalone.jar /te-bench/te-bench-standalone.jar

EXPOSE 8080

ENV PORT=8080
ENV JAVA_OPTS="-XX:+UseContainerSupport -Dfile.encoding=UTF-8"
ENV JDBC_URL="jdbc:postgresql://tfb-database/hello_world?user=benchmarkdbuser&password=benchmarkdbpass"

ENTRYPOINT exec java $JAVA_OPTS -jar /te-bench/te-bench-standalone.jar
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
[next.jdbc.result-set :as rs]
[jj.majavat :as majavat]
[jj.sql.boa :as boa]
[hiccup.page :as hp]
[hiccup.util :as hu]
[jj.majavat.renderer :refer [->StringRenderer]]
[jj.majavat.renderer.sanitizer :refer [->Html]]
[ring.util.http-response :as http-response]
Expand All @@ -20,6 +22,21 @@
(def ^:private render-fortune (majavat/build-renderer "html/fortunes.html"
{:renderer (->StringRenderer
{:sanitizer (->Html)})}))

(defn render-hiccup-fortune [fortunes]
(hp/html5
[:head
[:title "Fortunes"]]
[:body
[:table
[:tr
[:th "id"]
[:th "message"]]
(for [x fortunes]
[:tr
[:td (:id x)]
[:td (hu/escape-html (:message x))]])]]))

(def query-fortunes (boa/execute (boa/->NextJdbcAdapter) "sql/fortunes.sql"))
(def selmer-opts {:custom-resource-path (clojure.java.io/resource "html")})

Expand All @@ -35,6 +52,10 @@
(http-response/ok)
(http-response/content-type "text/html; charset=utf-8")))

(defn hiccup-html-response
[body]
(-> (http-response/ok body)
(http-response/content-type "text/html; charset=utf-8")))

(defn rand-id
[n]
Expand Down Expand Up @@ -148,4 +169,12 @@
(as-> (query-fortunes db-conn) fortunes
(conj fortunes {:id 0 :message "Additional fortune added at request time."})
(sort-by :message fortunes)
(majavat-html-response {:messages fortunes})))
(majavat-html-response {:messages fortunes})))

(defn hiccup-fortune-handler
[db-conn _request]
(as-> (query-fortunes db-conn) fortunes
(conj fortunes {:id 0 :message "Additional fortune added at request time."})
(sort-by :message fortunes)
(render-hiccup-fortune fortunes)
(hiccup-html-response fortunes)))
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
["/updates" {:get (partial bench/update-db-handler db-conn)}]
["/cached-queries" {:get (partial bench/cached-query-handler db-conn cache)}]
["/fortunes" {:get (partial bench/selmer-fortune-handler db-conn)}]
["/majavat-fortunes" {:get (partial bench/majavat-fortune-handler db-conn)}]])
["/majavat-fortunes" {:get (partial bench/majavat-fortune-handler db-conn)}]
["/hiccup-fortunes" {:get (partial bench/hiccup-fortune-handler db-conn)}]
])

(defmethod ig/init-key :reitit.routes/bench
[_ {:keys [base-path]
Expand Down
3 changes: 2 additions & 1 deletion frameworks/Clojure/reitit/benchmark_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@
"database_os": "Linux",
"display_name": "reitit-async",
"notes": "",
"versus": "undertow"
"versus": "undertow",
"tags": ["broken"]
}
}]
}
2 changes: 1 addition & 1 deletion frameworks/Clojure/reitit/reitit-async.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ COPY project.clj project.clj
COPY src src
RUN lein uberjar

FROM openjdk:25-jdk-slim
FROM amazoncorretto:25
WORKDIR /reitit
COPY --from=lein /reitit/target/hello-reitit-standalone.jar app.jar

Expand Down
2 changes: 1 addition & 1 deletion frameworks/Clojure/reitit/reitit-jdbc.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ COPY project.clj project.clj
COPY src src
RUN lein uberjar

FROM openjdk:25-jdk-slim
FROM amazoncorretto:25
WORKDIR /reitit
COPY --from=lein /reitit/target/hello-reitit-standalone.jar app.jar

Expand Down
2 changes: 1 addition & 1 deletion frameworks/Clojure/reitit/reitit.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ COPY project.clj project.clj
COPY src src
RUN lein uberjar

FROM openjdk:25-jdk-slim
FROM amazoncorretto:25
WORKDIR /reitit
COPY --from=lein /reitit/target/hello-reitit-standalone.jar app.jar

Expand Down
2 changes: 1 addition & 1 deletion frameworks/Clojure/reitit/src/hello/handler.clj
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
:else (constantly nil))]
(-> (ring/ring-handler
(ring/router
[["/plaintext" (exchange/constantly plain-text-handler)]
[["/plaintext" plain-text-handler]
["/json" json-handler]
["/db" db-handler]])
(ring/create-default-handler)
Expand Down
3 changes: 1 addition & 2 deletions frameworks/Clojure/ring-http-exchange/project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@
[org.clojars.jj/majavat "1.12.3"]
[hikari-cp "3.3.0"]
[org.clojars.jj/boa-sql "1.0.0"]
[io.netty/netty-transport-native-epoll "4.2.7.Final" :classifier "linux-x86_64"]
[org.postgresql/postgresql "42.7.8"]
[metosin/jsonista "0.3.13"]
]

:profiles {:robaho {:dependencies [[io.github.robaho/httpserver "1.0.28"]]}}
:profiles {:robaho {:dependencies [[io.github.robaho/httpserver "1.0.29"]]}}
:resource-paths ["resources"]
:main ring-http-exchange.benchmark)
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[ring-http-exchange.core :as server])
(:import
(com.zaxxer.hikari HikariDataSource)
(io.netty.channel.epoll EpollEventLoopGroup)))
(java.util.concurrent Executors)))

(def query-fortunes (boa/execute (boa/->NextJdbcAdapter) "fortune.sql"))

Expand All @@ -21,7 +21,7 @@
:idle-timeout 600000
:max-lifetime 1800000
:minimum-idle 16
:maximum-pool-size 64
:maximum-pool-size 520
:register-mbeans false
:jdbcUrl "jdbc:postgresql://tfb-database/hello_world?user=benchmarkdbuser&password=benchmarkdbpass"})

Expand All @@ -31,14 +31,18 @@
"Content-Type" "text/html; charset=UTF-8"})
(def ^:private ^:const json-headers {"Server" "ring-http-exchange"
"Content-Type" "application/json"})
(def ^:private ^:const plaintext-response {:status 200
:headers {"Server" "ring-http-exchange"
"Content-Type" "text/plain"}
:body "Hello, World!"})

(def ^:private render-fortune (majavat/build-renderer "fortune.html"
{:renderer (->StringRenderer
{:sanitizer (->Html)})}))


(defn- plaintext-response []
{:status 200
:headers {"Server" "ring-http-exchange"
"Content-Type" "text/plain"}
:body "Hello, World!"})

(defn- get-body [datasource]
(let [context (as-> (query-fortunes datasource) fortunes
(conj fortunes additional-message)
Expand All @@ -52,14 +56,15 @@
(server/run-http-server
(fn [req]
(case (req :uri)
"/plaintext" (plaintext-response)
"/json" {:status 200
:headers json-headers
:body (json/write-value-as-bytes {:message "Hello, World!"})}
"/fortunes" (let [body (get-body datasource)]
{:status 200
:headers fortune-headers
:body body})
plaintext-response))
(plaintext-response)))
{:port 8080
:host "0.0.0.0"
:executor (EpollEventLoopGroup.)})))
:executor (Executors/newVirtualThreadPerTaskExecutor)})))
Loading