Skip to content
Open
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ _Order is alphabetical_
* Hexagon
* Http4k (Jetty & Netty)
* Jetty
* JLHTTP
* Ktor (Jetty & Netty)
* NanoHttp
* Netty
Expand Down
7 changes: 7 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,13 @@
<version>5.3.4</version>
</dependency>

<!-- JLHTTP -->
<dependency>
<groupId>net.freeutils</groupId>
<artifactId>jlhttp</artifactId>
<version>2.4</version>
</dependency>

<!-- nanohttpd-->
<dependency>
<groupId>org.nanohttpd</groupId>
Expand Down
2 changes: 2 additions & 0 deletions src/org/kotlin/community/http/benchmarks/Benchmarks.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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.*
Expand Down Expand Up @@ -37,6 +38,7 @@ private fun BenchmarkSettings.setup() {
run<FluentHttpBenchmark>()
run<GrizzlyBenchmark>()
run<JettyBenchmark>()
run<JLHTTPBenchmark>()
run<HexagonBenchmark>()
run<Http4kJettyBenchmark>()
run<Http4kNettyBenchmark>()
Expand Down
36 changes: 36 additions & 0 deletions src/org/kotlin/community/http/benchmarks/jlhttp/JLHTTPBenchmark.kt
Original file line number Diff line number Diff line change
@@ -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<String>) {
benchmark(args) {
run<JLHTTPBenchmark>()
}
}


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()
}
}