diff --git a/README.md b/README.md index cb1fa75..48436f3 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ _Order is alphabetical_ * Hexagon * Http4k (Jetty & Netty) * Jetty +* JLHTTP * Ktor (Jetty & Netty) * NanoHttp * Netty diff --git a/pom.xml b/pom.xml index 8eab417..1bf49f7 100644 --- a/pom.xml +++ b/pom.xml @@ -142,6 +142,13 @@ 5.3.4 + + + net.freeutils + jlhttp + 2.4 + + org.nanohttpd diff --git a/src/org/kotlin/community/http/benchmarks/Benchmarks.kt b/src/org/kotlin/community/http/benchmarks/Benchmarks.kt index 1a386ae..32dc468 100644 --- a/src/org/kotlin/community/http/benchmarks/Benchmarks.kt +++ b/src/org/kotlin/community/http/benchmarks/Benchmarks.kt @@ -6,6 +6,7 @@ import org.kotlin.community.http.benchmarks.fluenthttp.* import org.kotlin.community.http.benchmarks.grizzly.* import org.kotlin.community.http.benchmarks.hexagon.* import org.kotlin.community.http.benchmarks.jetty.* +import org.kotlin.community.http.benchmarks.jlhttp.* import org.kotlin.community.http.benchmarks.http4k.* import org.kotlin.community.http.benchmarks.ktor.* import org.kotlin.community.http.benchmarks.nanohttpd.* @@ -37,6 +38,7 @@ private fun BenchmarkSettings.setup() { run() run() run() + run() run() run() run() diff --git a/src/org/kotlin/community/http/benchmarks/jlhttp/JLHTTPBenchmark.kt b/src/org/kotlin/community/http/benchmarks/jlhttp/JLHTTPBenchmark.kt new file mode 100644 index 0000000..9a39b75 --- /dev/null +++ b/src/org/kotlin/community/http/benchmarks/jlhttp/JLHTTPBenchmark.kt @@ -0,0 +1,36 @@ +package org.kotlin.community.http.benchmarks.jlhttp + +import net.freeutils.httpserver.HTTPServer +import net.freeutils.httpserver.HTTPServer.* +import org.kotlin.community.http.benchmarks.* +import java.util.concurrent.ExecutorService +import java.util.concurrent.Executors + +fun main(args: Array) { + benchmark(args) { + run() + } +} + + +open class JLHTTPBenchmark : HttpBenchmarkBase() { + private lateinit var server : HTTPServer + private lateinit var executor: ExecutorService + override fun startServer(port: Int) { + executor = Executors.newCachedThreadPool() + server = HTTPServer(port) + server.setSocketTimeout(1000) + server.setExecutor(executor) + val host = server.getVirtualHost(null) + host.addContext("/", ContextHandler { req, resp -> + resp.send(200, "Hello") + 0 + }) + server.start() + } + + override fun stopServer() { + server.stop() + executor.shutdown() + } +}