Skip to content
Merged
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 @@ -25,6 +25,24 @@
"display_name": "Kit",
"notes": "",
"versus": "None"
},
"majavat": {
"fortune_url": "/majavat-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-majavat",
"notes": "",
"versus": "kit"
}
}
]
Expand Down
24 changes: 13 additions & 11 deletions frameworks/Clojure/kit/deps.edn
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
{:paths ["src/clj"
"resources"]

:deps {org.clojure/clojure {:mvn/version "1.11.1"}
:deps {org.clojure/clojure {:mvn/version "1.12.3"}

;; Routing
metosin/reitit {:mvn/version "0.5.18"}
metosin/reitit {:mvn/version "0.9.1"}

;; Ring
metosin/ring-http-response {:mvn/version "0.9.3"}
ring/ring-core {:mvn/version "1.9.5"}
metosin/ring-http-response {:mvn/version "0.9.5"}
ring/ring-core {:mvn/version "1.15.3"}

;; Data coercion
metosin/muuntaja {:mvn/version "0.6.8"}
metosin/muuntaja {:mvn/version "0.6.11"}

;; HTML templating
selmer/selmer {:mvn/version "1.12.55"}
selmer/selmer {:mvn/version "1.12.62"}
org.clojars.jj/majavat {:mvn/version "1.12.1"}

;; Database
org.postgresql/postgresql {:mvn/version "42.5.1"}
org.postgresql/postgresql {:mvn/version "42.7.8"}


;; kit Libs
io.github.kit-clj/kit-core {:mvn/version "1.0.3"}
io.github.kit-clj/kit-undertow {:mvn/version "1.0.4"}
io.github.kit-clj/kit-sql-hikari {:mvn/version "1.0.2"}
org.clojure/core.cache {:mvn/version "1.0.225"}
io.github.kit-clj/kit-core {:mvn/version "1.0.9"}
io.github.kit-clj/kit-undertow {:mvn/version "1.0.9"}
io.github.kit-clj/kit-sql-hikari {:mvn/version "1.0.6"}
org.clojure/core.cache {:mvn/version "1.1.234"}

}

Expand Down
19 changes: 19 additions & 0 deletions frameworks/Clojure/kit/kit-majavat.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 azul/zulu-openjdk-alpine:17

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 @@ -17,11 +17,10 @@

;; log uncaught exceptions in threads
(Thread/setDefaultUncaughtExceptionHandler
(reify Thread$UncaughtExceptionHandler
(uncaughtException [_ thread ex]
(log/error {:what :uncaught-exception
:exception ex
:where (str "Uncaught exception on" (.getName thread))}))))
(fn [thread ex]
(log/error {:what :uncaught-exception
:exception ex
:where (str "Uncaught exception on" (.getName thread))})))

(defonce system (atom nil))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
[clojure.core.cache :as cache]
[next.jdbc :as jdbc]
[next.jdbc.result-set :as rs]
[jj.majavat :as majavat]
[jj.majavat.renderer :refer [->InputStreamRenderer]]
[jj.majavat.renderer.sanitizer :refer [->Html]]
[ring.util.http-response :as http-response]
[selmer.parser :as parser]))

Expand All @@ -13,15 +16,24 @@
(def ^:const HELLO_WORLD "Hello, World!")
(def ^:const MAX_ID_ZERO_IDX 9999)
(def ^:const CACHE_TTL (* 24 60 60))

(def ^:private render-fortune (majavat/build-renderer "html/fortunes.html"
{:renderer (->InputStreamRenderer
{:sanitizer (->Html)})}))
(def selmer-opts {:custom-resource-path (clojure.java.io/resource "html")})

(defn html-response
(defn selmer-html-response
[template & [params]]
(-> (parser/render-file template params selmer-opts)
(http-response/ok)
(http-response/content-type "text/html; charset=utf-8")))

(defn majavat-html-response
[context]
(-> (render-fortune context)
(http-response/ok)
(http-response/content-type "text/html; charset=utf-8")))


(defn rand-id
[n]
(inc (rand-int n)))
Expand All @@ -31,7 +43,7 @@
"Parse provided string value of query count, clamping values to between 1 and 500."
[^String queries]
(let [n (try (Integer/parseInt queries)
(catch Exception _ 1))] ; default to 1 on parse failure
(catch Exception _ 1))] ; default to 1 on parse failure
(cond
(< n 1) 1
(> n 500) 500
Expand Down Expand Up @@ -101,7 +113,7 @@

(defn update-db-handler
[db-conn request]
(let [items (db-multi-query-world! db-conn request)]
(let [items (db-multi-query-world! db-conn request)]
(http-response/ok
(mapv
(fn [{:keys [id]}]
Expand All @@ -122,9 +134,16 @@
[]
(range-from-req request))))

(defn fortune-handler
(defn selmer-fortune-handler
[db-conn _request]
(as-> (jdbc/execute! db-conn ["select * from \"Fortune\";"] jdbc-opts) fortunes
(conj fortunes {:id 0 :message "Additional fortune added at request time."})
(sort-by :message fortunes)
(selmer-html-response "fortunes.html" {:messages fortunes})))

(defn majavat-fortune-handler
[db-conn _request]
(as-> (jdbc/execute! db-conn ["select * from \"Fortune\";"] jdbc-opts) fortunes
(conj fortunes {:id 0 :message "Additional fortune added at request time."})
(sort-by :message fortunes)
(html-response "fortunes.html" {:messages fortunes})))
(majavat-html-response {:messages fortunes})))
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,16 @@
["/queries" {:get (partial bench/multi-db-handler db-conn)}]
["/updates" {:get (partial bench/update-db-handler db-conn)}]
["/cached-queries" {:get (partial bench/cached-query-handler db-conn cache)}]
["/fortunes" {:get (partial bench/fortune-handler db-conn)}]])
["/fortunes" {:get (partial bench/selmer-fortune-handler db-conn)}]
["/majavat-fortunes" {:get (partial bench/majavat-fortune-handler db-conn)}]])

(defmethod ig/init-key :reitit.routes/bench
[_ {:keys [base-path]
:or {base-path ""}
:as opts}]
[base-path
{:muuntaja formats/instance
:middleware [;; query-params & form-params
parameters/parameters-middleware
;; encoding response body
:middleware [parameters/parameters-middleware
muuntaja/format-response-middleware
;; default header middleware
default-headers/default-headers-middleware]}
(bench-routes opts)])
20 changes: 12 additions & 8 deletions frameworks/Clojure/ring-http-exchange/benchmark_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
"default": {
"json_url": "/json",
"plaintext_url": "/plaintext",
"fortune_url": "/fortunes",
"port": 8080,
"approach": "Realistic",
"classification": "Platform",
"database": "None",
"database": "postgres",
"framework": "None",
"language": "Clojure",
"flavor": "None",
"orm": "None",
"orm": "Raw",
"platform": "None",
"webserver": "None",
"os": "Linux",
Expand All @@ -24,14 +25,15 @@
"robaho": {
"json_url": "/json",
"plaintext_url": "/plaintext",
"fortune_url": "/fortunes",
"port": 8080,
"approach": "Realistic",
"classification": "Platform",
"database": "None",
"database": "postgres",
"framework": "None",
"language": "Clojure",
"flavor": "None",
"orm": "None",
"orm": "Raw",
"platform": "None",
"webserver": "None",
"os": "Linux",
Expand All @@ -43,14 +45,15 @@
"graalvm": {
"json_url": "/json",
"plaintext_url": "/plaintext",
"fortune_url": "/fortunes",
"port": 8080,
"approach": "Realistic",
"classification": "Platform",
"database": "None",
"database": "postgres",
"framework": "None",
"language": "Clojure",
"flavor": "None",
"orm": "None",
"orm": "Raw",
"platform": "None",
"webserver": "None",
"os": "Linux",
Expand All @@ -62,14 +65,15 @@
"robaho-graalvm": {
"json_url": "/json",
"plaintext_url": "/plaintext",
"fortune_url": "/fortunes",
"port": 8080,
"approach": "Realistic",
"classification": "Platform",
"database": "None",
"database": "postgres",
"framework": "None",
"language": "Clojure",
"flavor": "None",
"orm": "None",
"orm": "Raw",
"platform": "None",
"webserver": "None",
"os": "Linux",
Expand Down
12 changes: 8 additions & 4 deletions frameworks/Clojure/ring-http-exchange/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ name = "ring-http-exchange"
[main]
urls.plaintext = "/plaintext"
urls.json = "/json"
urls.fortune = "/fortunes"
approach = "Realistic"
classification = "Platform"
database = "None"
database = "postgres"
database_os = "Linux"
os = "Linux"
orm = "Raw"
Expand All @@ -18,9 +19,10 @@ versus = "httpserver"
[graalvm]
urls.plaintext = "/plaintext"
urls.json = "/json"
urls.fortune = "/fortunes"
approach = "Realistic"
classification = "Platform"
database = "None"
database = "postgres"
database_os = "Linux"
os = "Linux"
orm = "Raw"
Expand All @@ -31,9 +33,10 @@ versus = "httpserver-graalvm"
[robaho]
urls.plaintext = "/plaintext"
urls.json = "/json"
urls.fortune = "/fortunes"
approach = "Realistic"
classification = "Platform"
database = "None"
database = "postgres"
database_os = "Linux"
os = "Linux"
orm = "Raw"
Expand All @@ -44,9 +47,10 @@ versus = "httpserver-robaho"
[robaho-graalvm]
urls.plaintext = "/plaintext"
urls.json = "/json"
urls.fortune = "/fortunes"
approach = "Realistic"
classification = "Platform"
database = "None"
database = "postgres"
database_os = "Linux"
os = "Linux"
orm = "Raw"
Expand Down
Loading
Loading