Skip to content

Commit a208b21

Browse files
Merge branch 'TechEmpower:master' into rust/axum
2 parents 1b2e4d4 + f1e5b50 commit a208b21

File tree

235 files changed

+3812
-3218
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

235 files changed

+3812
-3218
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# ring-http-exchange Benchmarking Test
2+
3+
## Test Type Implementation Source Code
4+
* [JSON](src/ring_http_exchange/benchmark.clj)
5+
* [PLAINTEXT](src/ring_http_exchange/benchmark.clj)
6+
7+
## Important Libraries
8+
The tests were run with:
9+
* [ring-http-exchange](https://github.com/ruroru/ring-http-exchange)
10+
* [jsonista](https://github.com/metosin/jsonista)
11+
12+
## Test URLs
13+
### JSON
14+
http://localhost:8080/json
15+
16+
### PLAINTEXT
17+
http://localhost:8080/plaintext
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"framework": "ring-http-exchange",
3+
"tests": [
4+
{
5+
"default": {
6+
"json_url": "/json",
7+
"plaintext_url": "/plaintext",
8+
"port": 8080,
9+
"approach": "Realistic",
10+
"classification": "Platform",
11+
"database": "None",
12+
"framework": "None",
13+
"language": "Clojure",
14+
"flavor": "None",
15+
"orm": "None",
16+
"platform": "None",
17+
"webserver": "None",
18+
"os": "Linux",
19+
"database_os": "Linux",
20+
"display_name": "ring-http-exchange",
21+
"notes": "",
22+
"versus": "httpserver"
23+
}
24+
},
25+
{
26+
"robaho": {
27+
"json_url": "/json",
28+
"plaintext_url": "/plaintext",
29+
"port": 8080,
30+
"approach": "Realistic",
31+
"classification": "Platform",
32+
"database": "None",
33+
"framework": "None",
34+
"language": "Clojure",
35+
"flavor": "None",
36+
"orm": "None",
37+
"platform": "None",
38+
"webserver": "None",
39+
"os": "Linux",
40+
"database_os": "Linux",
41+
"display_name": "ring-http-exchange-robaho",
42+
"notes": "",
43+
"versus": "ring-http-exchange"
44+
}
45+
}
46+
]
47+
}
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<groupId>ring-http-server</groupId>
6+
<artifactId>ring-http-server</artifactId>
7+
<packaging>jar</packaging>
8+
<version>1.0.0</version>
9+
<name>ring-http-server</name>
10+
<licenses>
11+
<license>
12+
<name>EPL-2.0</name>
13+
<url>https://www.eclipse.org/legal/epl-2.0/</url>
14+
</license>
15+
</licenses>
16+
<build>
17+
<sourceDirectory>java</sourceDirectory>
18+
<testSourceDirectory>java-test</testSourceDirectory>
19+
<resources>
20+
<resource>
21+
<directory>resources</directory>
22+
</resource>
23+
</resources>
24+
<testResources>
25+
<testResource>
26+
<directory>resources</directory>
27+
</testResource>
28+
</testResources>
29+
<directory>target</directory>
30+
<outputDirectory>target\classes</outputDirectory>
31+
<plugins>
32+
<plugin>
33+
<groupId>com.theoryinpractise</groupId>
34+
<artifactId>clojure-maven-plugin</artifactId>
35+
<version>1.8.3</version>
36+
<extensions>true</extensions>
37+
<executions>
38+
<execution>
39+
<id>compile-clojure</id>
40+
<phase>compile</phase>
41+
<goals>
42+
<goal>compile</goal>
43+
</goals>
44+
</execution>
45+
<execution>
46+
<id>test-clojure</id>
47+
<phase>test</phase>
48+
<goals>
49+
<goal>test</goal>
50+
</goals>
51+
</execution>
52+
</executions>
53+
<configuration>
54+
<sourceDirectories>
55+
<sourceDirectory>src/</sourceDirectory>
56+
</sourceDirectories>
57+
</configuration>
58+
</plugin>
59+
<plugin>
60+
<artifactId>maven-assembly-plugin</artifactId>
61+
<configuration>
62+
<archive>
63+
<manifest>
64+
<mainClass>ring_http_exchange.benchmark</mainClass>
65+
</manifest>
66+
</archive>
67+
<descriptorRefs>
68+
<descriptorRef>jar-with-dependencies</descriptorRef>
69+
</descriptorRefs>
70+
</configuration>
71+
<executions>
72+
<execution>
73+
<id>make-assembly</id>
74+
<phase>package</phase>
75+
<goals>
76+
<goal>single</goal>
77+
</goals>
78+
</execution>
79+
</executions>
80+
</plugin>
81+
</plugins>
82+
</build>
83+
<repositories>
84+
<repository>
85+
<id>central</id>
86+
<url>https://repo1.maven.org/maven2/</url>
87+
<snapshots>
88+
<enabled>false</enabled>
89+
</snapshots>
90+
<releases>
91+
<enabled>true</enabled>
92+
</releases>
93+
</repository>
94+
<repository>
95+
<id>clojars</id>
96+
<url>https://repo.clojars.org/</url>
97+
<snapshots>
98+
<enabled>true</enabled>
99+
</snapshots>
100+
<releases>
101+
<enabled>true</enabled>
102+
</releases>
103+
</repository>
104+
</repositories>
105+
<dependencyManagement>
106+
<dependencies/>
107+
</dependencyManagement>
108+
<dependencies>
109+
<dependency>
110+
<groupId>org.clojure</groupId>
111+
<artifactId>clojure</artifactId>
112+
<version>1.11.2</version>
113+
</dependency>
114+
<dependency>
115+
<groupId>org.clojars.jj</groupId>
116+
<artifactId>ring-http-exchange</artifactId>
117+
<version>1.1.0</version>
118+
</dependency>
119+
<dependency>
120+
<groupId>metosin</groupId>
121+
<artifactId>jsonista</artifactId>
122+
<version>0.3.13</version>
123+
</dependency>
124+
</dependencies>
125+
<profiles>
126+
<profile>
127+
<id>robaho</id>
128+
<activation>
129+
<activeByDefault>false</activeByDefault>
130+
</activation>
131+
<dependencies>
132+
<dependency>
133+
<groupId>io.github.robaho</groupId>
134+
<artifactId>httpserver</artifactId>
135+
<version>1.0.23</version>
136+
</dependency>
137+
</dependencies>
138+
</profile>
139+
</profiles>
140+
</project>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM maven:3-eclipse-temurin-24-alpine as maven
2+
WORKDIR /ring-http-exchange
3+
COPY pom.xml pom.xml
4+
COPY src src
5+
RUN mvn clean clojure:compile -P robaho package
6+
7+
FROM openjdk:25-jdk-slim
8+
WORKDIR /ring-http-exchange
9+
COPY --from=maven /ring-http-exchange/target/ring-http-server-1.0.0-jar-with-dependencies.jar app.jar
10+
11+
EXPOSE 8080
12+
13+
CMD ["java", "-server", "-XX:+UseParallelGC", "-jar", "app.jar"]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM maven:3-eclipse-temurin-24-alpine as maven
2+
WORKDIR /ring-http-exchange
3+
COPY pom.xml pom.xml
4+
COPY src src
5+
RUN mvn clean clojure:compile package
6+
7+
FROM openjdk:25-jdk-slim
8+
WORKDIR /ring-http-exchange
9+
COPY --from=maven /ring-http-exchange/target/ring-http-server-1.0.0-jar-with-dependencies.jar app.jar
10+
11+
EXPOSE 8080
12+
13+
CMD ["java", "-server", "-XX:+UseParallelGC", "-jar", "app.jar"]
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
(ns ring-http-exchange.benchmark
2+
(:gen-class)
3+
(:require [jsonista.core :as json]
4+
[ring-http-exchange.core :as server])
5+
(:import
6+
(java.util.concurrent Executors)))
7+
8+
(def ^:private ^:const json-headers {"Server" "ring-http-exchange"
9+
"Content-Type" "application/json"})
10+
(def ^:private ^:const plaintext-response
11+
{:status 200
12+
:headers {
13+
"Server" "ring-http-exchange"
14+
"Content-Type" "text/plain"}
15+
:body "Hello, World!"})
16+
17+
(defn -main
18+
[& args]
19+
(println "Starting server on port 8080")
20+
(server/run-http-server
21+
(fn [req]
22+
(case (req :uri)
23+
"/json" {:status 200
24+
:headers json-headers
25+
:body (json/write-value-as-bytes {:message "Hello, World!"})}
26+
plaintext-response))
27+
{:port 8080
28+
:host "0.0.0.0"
29+
:executor (Executors/newVirtualThreadPerTaskExecutor)}))

frameworks/Dart/dart3/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
# Created by `dart pub`
33
.dart_tool/
44
*.lock
5-
!bin
5+
!bin

frameworks/Dart/dart3/bin/server.dart

Lines changed: 27 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,22 @@ import 'dart:convert';
22
import 'dart:io';
33
import 'dart:isolate';
44

5-
final _encoder = JsonUtf8Encoder();
6-
7-
void main(List<String> _) async {
8-
/// Create an [Isolate] containinig an [HttpServer]
5+
void main(List<String> args) async {
6+
/// Create an [Isolate] containing an [HttpServer]
97
/// for each processor after the first
108
for (var i = 1; i < Platform.numberOfProcessors; i++) {
11-
await Isolate.spawn(_startServer, _);
9+
await Isolate.spawn(_startServer, args);
1210
}
1311

1412
/// Create a [HttpServer] for the first processor
15-
await _startServer(_);
13+
await _startServer(args);
1614
}
1715

1816
/// Creates and setup a [HttpServer]
1917
Future<void> _startServer(List<String> _) async {
2018
/// Binds the [HttpServer] on `0.0.0.0:8080`.
2119
final server = await HttpServer.bind(
22-
InternetAddress('0.0.0.0', type: InternetAddressType.IPv4),
20+
InternetAddress.anyIPv4,
2321
8080,
2422
shared: true,
2523
);
@@ -51,39 +49,35 @@ void _sendResponse(
5149
int statusCode, {
5250
ContentType? type,
5351
List<int> bytes = const [],
54-
}) =>
55-
request.response
56-
..statusCode = statusCode
57-
..headers.contentType = type
58-
..headers.date = DateTime.now()
59-
..contentLength = bytes.length
60-
..add(bytes)
61-
..close();
52+
}) => request.response
53+
..statusCode = statusCode
54+
..headers.contentType = type
55+
..headers.date = DateTime.now()
56+
..contentLength = bytes.length
57+
..add(bytes)
58+
..close();
6259

6360
/// Completes the given [request] by writing the [response] as JSON.
6461
void _sendJson(HttpRequest request, Object response) => _sendResponse(
65-
request,
66-
HttpStatus.ok,
67-
type: ContentType.json,
68-
bytes: _encoder.convert(response),
69-
);
62+
request,
63+
HttpStatus.ok,
64+
type: ContentType.json,
65+
bytes: _jsonEncoder.convert(response),
66+
);
7067

7168
/// Completes the given [request] by writing the [response] as plain text.
7269
void _sendText(HttpRequest request, String response) => _sendResponse(
73-
request,
74-
HttpStatus.ok,
75-
type: ContentType.text,
76-
bytes: utf8.encode(response),
77-
);
70+
request,
71+
HttpStatus.ok,
72+
type: ContentType.text,
73+
bytes: utf8.encode(response),
74+
);
7875

7976
/// Responds with the JSON test to the [request].
80-
void _jsonTest(HttpRequest request) => _sendJson(
81-
request,
82-
const {'message': 'Hello, World!'},
83-
);
77+
void _jsonTest(HttpRequest request) =>
78+
_sendJson(request, const {'message': 'Hello, World!'});
8479

8580
/// Responds with the plaintext test to the [request].
86-
void _plaintextTest(HttpRequest request) => _sendText(
87-
request,
88-
'Hello, World!',
89-
);
81+
void _plaintextTest(HttpRequest request) => _sendText(request, 'Hello, World!');
82+
83+
final _jsonEncoder = JsonUtf8Encoder();

frameworks/Dart/dart3/dart3.dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
FROM dart:3.5 AS builder
2+
FROM dart:3.8 AS builder
33

44
COPY . /app
55
WORKDIR /app
@@ -11,4 +11,4 @@ COPY --from=builder /runtime/ /
1111
COPY --from=builder /app/build /bin
1212

1313
EXPOSE 8080
14-
CMD ["server"]
14+
CMD ["server"]

frameworks/Dart/dart3/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: dartbenchmark
22
description: A benchmark of dart
33
environment:
4-
sdk: '>=3.5.0 <4.0.0'
4+
sdk: ^3.8.0
55

66
dev_dependencies:
77
lints: ^4.0.0

0 commit comments

Comments
 (0)