Utilities and Scripts
Kwrk
kwrk
is a benchmark utility, implemented in Kotlin using the Tulip runtime, which is similar in functionality to wrk
and wrk2
. See article "Getting started with wrk and wrk2 benchmarking" for more information on using these two HTTP benchmark utilities.
kwrk
records benchmark latencies using HdrHistogram
, and a future version will display a detailed percentile report of response times just like wrk2
does.
Usage: kwrk [<options>]
Options:
--rps=<float> # default value is 5.0
--threads=<int> # default value is 2
--duration=<int> # default value is 30 seconds
--iterations=<int> # default value is 3
--url=<text> # no default value
-h, --help Show this message and exit
Benchmark 1 at 10 RPS
This test sends HTTP requests at a rate of 10 requests per second (rps) to <jsonplaceholder>/posts/1.
jbang run kwrk@wfouche --rps=10.0 --url=http://jsonplaceholder.typicode.com/posts/1
kwrk:
--rps 10.0
--threads 2
--duration 30
--iterations 3
--url http://jsonplaceholder.typicode.com/posts/1
Tulip 2.1.5 (Java: Microsoft 21.0.6+7-LTS, Kotlin: 2.0.21)
....
....
Output filename = kwrk_output.json
Report filename = kwrk_report.html
Open file kwrk_report.html
in a browser to view the benchmark results.
![]() |
Benchmark 2 at 10,000 RPS
This test sends HTTP requests at a rate of 10,000 requests per second (rps) to <localhost:7070>/posts/1.
Open two terminal windows. Run the Test Http Service in the first terminal window, and kwrk in the second terminal window.
jbang run HttpService.java
[main] INFO io.javalin.Javalin - Javalin started in 526ms \o/
[main] INFO io.javalin.Javalin - Listening on http://localhost:7070/
[main] INFO io.javalin.Javalin - You are running Javalin 6.4.0 (released December 17, 2024).
jbang run kwrk@wfouche --rps=10000.0 --url=http://localhost:7070/posts/1
kwrk:
--rps 10000.0
--threads 2
--duration 30
--iterations 3
--url http://localhost:7070/posts/1
Tulip 2.1.5 (Java: Microsoft 21.0.6+7-LTS, Kotlin: 2.0.21)
....
....
Output filename = kwrk_output.json
Report filename = kwrk_report.html
The benchmark results are again written to report kwrk_report.html
.
![]() |
Test Http Service
$ jbang run HttpService.java
///usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS io.javalin:javalin:6.4.0
//DEPS org.slf4j:slf4j-simple:2.0.16
// https://javalin.io/
import io.javalin.Javalin;
public class HttpService {
public static void main(String[] args) {
var app = Javalin.create(/*config*/)
.get("/posts/{id}", ctx -> ctx.result("{\"code\": \"OK\"}")
.contentType("application/json") )
.start(7070);
}
}
// curl http://localhost:7070/posts/1
// {"code": "OK"}