Browse Source

Add ring-http-exchange (#9948)

ruroru 2 months ago
parent
commit
5f109a0ec5

+ 17 - 0
frameworks/Clojure/ring-http-exchange/README.md

@@ -0,0 +1,17 @@
+# ring-http-exchange Benchmarking Test
+
+## Test Type Implementation Source Code
+* [JSON](src/ring_http_exchange/benchmark.clj)
+* [PLAINTEXT](src/ring_http_exchange/benchmark.clj)
+
+## Important Libraries
+The tests were run with:
+* [ring-http-exchange](https://github.com/ruroru/ring-http-exchange)
+* [jsonista](https://github.com/metosin/jsonista)
+
+## Test URLs
+### JSON
+http://localhost:8080/json
+
+### PLAINTEXT
+http://localhost:8080/plaintext

+ 47 - 0
frameworks/Clojure/ring-http-exchange/benchmark_config.json

@@ -0,0 +1,47 @@
+{
+  "framework": "ring-http-exchange",
+  "tests": [
+    {
+      "default": {
+        "json_url": "/json",
+        "plaintext_url": "/plaintext",
+        "port": 8080,
+        "approach": "Realistic",
+        "classification": "Platform",
+        "database": "None",
+        "framework": "None",
+        "language": "Clojure",
+        "flavor": "None",
+        "orm": "None",
+        "platform": "None",
+        "webserver": "None",
+        "os": "Linux",
+        "database_os": "Linux",
+        "display_name": "ring-http-exchange",
+        "notes": "",
+        "versus": "httpserver"
+      }
+    },
+    {
+      "robaho": {
+        "json_url": "/json",
+        "plaintext_url": "/plaintext",
+        "port": 8080,
+        "approach": "Realistic",
+        "classification": "Platform",
+        "database": "None",
+        "framework": "None",
+        "language": "Clojure",
+        "flavor": "None",
+        "orm": "None",
+        "platform": "None",
+        "webserver": "None",
+        "os": "Linux",
+        "database_os": "Linux",
+        "display_name": "ring-http-exchange-robaho",
+        "notes": "",
+        "versus": "ring-http-exchange"
+      }
+    }
+  ]
+}

+ 140 - 0
frameworks/Clojure/ring-http-exchange/pom.xml

@@ -0,0 +1,140 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>ring-http-server</groupId>
+    <artifactId>ring-http-server</artifactId>
+    <packaging>jar</packaging>
+    <version>1.0.0</version>
+    <name>ring-http-server</name>
+    <licenses>
+        <license>
+            <name>EPL-2.0</name>
+            <url>https://www.eclipse.org/legal/epl-2.0/</url>
+        </license>
+    </licenses>
+    <build>
+        <sourceDirectory>java</sourceDirectory>
+        <testSourceDirectory>java-test</testSourceDirectory>
+        <resources>
+            <resource>
+                <directory>resources</directory>
+            </resource>
+        </resources>
+        <testResources>
+            <testResource>
+                <directory>resources</directory>
+            </testResource>
+        </testResources>
+        <directory>target</directory>
+        <outputDirectory>target\classes</outputDirectory>
+        <plugins>
+            <plugin>
+                <groupId>com.theoryinpractise</groupId>
+                <artifactId>clojure-maven-plugin</artifactId>
+                <version>1.8.3</version>
+                <extensions>true</extensions>
+                <executions>
+                    <execution>
+                        <id>compile-clojure</id>
+                        <phase>compile</phase>
+                        <goals>
+                            <goal>compile</goal>
+                        </goals>
+                    </execution>
+                    <execution>
+                        <id>test-clojure</id>
+                        <phase>test</phase>
+                        <goals>
+                            <goal>test</goal>
+                        </goals>
+                    </execution>
+                </executions>
+                <configuration>
+                    <sourceDirectories>
+                        <sourceDirectory>src/</sourceDirectory>
+                    </sourceDirectories>
+                </configuration>
+            </plugin>
+            <plugin>
+                <artifactId>maven-assembly-plugin</artifactId>
+                <configuration>
+                    <archive>
+                        <manifest>
+                            <mainClass>ring_http_exchange.benchmark</mainClass>
+                        </manifest>
+                    </archive>
+                    <descriptorRefs>
+                        <descriptorRef>jar-with-dependencies</descriptorRef>
+                    </descriptorRefs>
+                </configuration>
+                <executions>
+                    <execution>
+                        <id>make-assembly</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>single</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+    <repositories>
+        <repository>
+            <id>central</id>
+            <url>https://repo1.maven.org/maven2/</url>
+            <snapshots>
+                <enabled>false</enabled>
+            </snapshots>
+            <releases>
+                <enabled>true</enabled>
+            </releases>
+        </repository>
+        <repository>
+            <id>clojars</id>
+            <url>https://repo.clojars.org/</url>
+            <snapshots>
+                <enabled>true</enabled>
+            </snapshots>
+            <releases>
+                <enabled>true</enabled>
+            </releases>
+        </repository>
+    </repositories>
+    <dependencyManagement>
+        <dependencies/>
+    </dependencyManagement>
+    <dependencies>
+        <dependency>
+            <groupId>org.clojure</groupId>
+            <artifactId>clojure</artifactId>
+            <version>1.11.1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.clojars.jj</groupId>
+            <artifactId>ring-http-exchange</artifactId>
+            <version>1.1.0</version>
+        </dependency>
+        <dependency>
+            <groupId>metosin</groupId>
+            <artifactId>jsonista</artifactId>
+            <version>0.3.13</version>
+        </dependency>
+    </dependencies>
+    <profiles>
+        <profile>
+            <id>robaho</id>
+            <activation>
+                <activeByDefault>false</activeByDefault>
+            </activation>
+            <dependencies>
+                <dependency>
+                    <groupId>io.github.robaho</groupId>
+                    <artifactId>httpserver</artifactId>
+                    <version>1.0.23</version>
+                </dependency>
+            </dependencies>
+        </profile>
+    </profiles>
+</project>

+ 13 - 0
frameworks/Clojure/ring-http-exchange/ring-http-exchange-robaho.dockerfile

@@ -0,0 +1,13 @@
+FROM maven:3-eclipse-temurin-24-alpine as maven
+WORKDIR /ring-http-exchange
+COPY pom.xml pom.xml
+COPY src src
+RUN mvn clean clojure:compile -P robaho package
+
+FROM openjdk:25-jdk-slim
+WORKDIR /ring-http-exchange
+COPY --from=maven /ring-http-exchange/target/ring-http-server-1.0.0-jar-with-dependencies.jar app.jar
+
+EXPOSE 8080
+
+CMD ["java", "-server", "-XX:+UseParallelGC", "-jar", "app.jar"]

+ 13 - 0
frameworks/Clojure/ring-http-exchange/ring-http-exchange.dockerfile

@@ -0,0 +1,13 @@
+FROM maven:3-eclipse-temurin-24-alpine as maven
+WORKDIR /ring-http-exchange
+COPY pom.xml pom.xml
+COPY src src
+RUN mvn clean clojure:compile package
+
+FROM openjdk:25-jdk-slim
+WORKDIR /ring-http-exchange
+COPY --from=maven /ring-http-exchange/target/ring-http-server-1.0.0-jar-with-dependencies.jar app.jar
+
+EXPOSE 8080
+
+CMD ["java", "-server", "-XX:+UseParallelGC", "-jar", "app.jar"]

+ 29 - 0
frameworks/Clojure/ring-http-exchange/src/ring_http_exchange/benchmark.clj

@@ -0,0 +1,29 @@
+(ns ring-http-exchange.benchmark
+    (:gen-class)
+    (:require [jsonista.core :as json]
+      [ring-http-exchange.core :as server])
+    (:import
+      (java.util.concurrent Executors)))
+
+(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!"})
+
+(defn -main
+      [& args]
+      (println "Starting server on port 8080")
+      (server/run-http-server
+        (fn [req]
+            (case (req :uri)
+                  "/json" {:status  200
+                           :headers json-headers
+                           :body    (json/write-value-as-bytes {:message "Hello, World!"})}
+                  plaintext-response))
+        {:port     8080
+         :host     "0.0.0.0"
+         :executor (Executors/newVirtualThreadPerTaskExecutor)}))