From e6fc43d09573279c5b475cb04572c4ebcec97b4c Mon Sep 17 00:00:00 2001 From: Julien Viet Date: Tue, 6 Jun 2017 21:55:47 +0200 Subject: [PATCH] Add support for Vertx Core --- .../community/http/benchmarks/Benchmarks.kt | 3 +- .../http/benchmarks/vertx/VertxBenchmark.kt | 11 ++---- .../benchmarks/vertxweb/VertxWebBenchmark.kt | 36 +++++++++++++++++++ 3 files changed, 40 insertions(+), 10 deletions(-) create mode 100644 src/org/kotlin/community/http/benchmarks/vertxweb/VertxWebBenchmark.kt diff --git a/src/org/kotlin/community/http/benchmarks/Benchmarks.kt b/src/org/kotlin/community/http/benchmarks/Benchmarks.kt index 1a386ae..0dddf07 100644 --- a/src/org/kotlin/community/http/benchmarks/Benchmarks.kt +++ b/src/org/kotlin/community/http/benchmarks/Benchmarks.kt @@ -14,7 +14,7 @@ import org.kotlin.community.http.benchmarks.ninjaframework.* import org.kotlin.community.http.benchmarks.rapidoid.* import org.kotlin.community.http.benchmarks.spark.* import org.kotlin.community.http.benchmarks.undertow.* -import org.kotlin.community.http.benchmarks.vertx.* +import org.kotlin.community.http.benchmarks.vertxweb.* fun main(args: Array) { benchmark(args) { @@ -48,6 +48,7 @@ private fun BenchmarkSettings.setup() { run() run() run() + run() run() } diff --git a/src/org/kotlin/community/http/benchmarks/vertx/VertxBenchmark.kt b/src/org/kotlin/community/http/benchmarks/vertx/VertxBenchmark.kt index 26c2a45..27fa75a 100644 --- a/src/org/kotlin/community/http/benchmarks/vertx/VertxBenchmark.kt +++ b/src/org/kotlin/community/http/benchmarks/vertx/VertxBenchmark.kt @@ -14,16 +14,9 @@ fun main(args: Array) { open class VertxBenchmark : HttpBenchmarkBase() { val vertx = Vertx.vertx() override fun startServer(port: Int) { - val router = Router.router(vertx).apply { - get("/").handler { request -> - request.response().putHeader("content-type", "text/plain").end("Hello") - } - //get().handler(StaticHandler.create("public")) - } - val f = CompletableFuture() - vertx.createHttpServer().requestHandler { - router.accept(it) + vertx.createHttpServer().requestHandler { request -> + request.response().putHeader("content-type", "text/plain").end("Hello") }.listen(port) { f.complete(Unit) } diff --git a/src/org/kotlin/community/http/benchmarks/vertxweb/VertxWebBenchmark.kt b/src/org/kotlin/community/http/benchmarks/vertxweb/VertxWebBenchmark.kt new file mode 100644 index 0000000..8f1c767 --- /dev/null +++ b/src/org/kotlin/community/http/benchmarks/vertxweb/VertxWebBenchmark.kt @@ -0,0 +1,36 @@ +package org.kotlin.community.http.benchmarks.vertxweb + +import io.vertx.core.* +import io.vertx.ext.web.* +import org.kotlin.community.http.benchmarks.* +import java.util.concurrent.* + +fun main(args: Array) { + benchmark(args) { + run() + } +} + +open class VertxWebBenchmark : HttpBenchmarkBase() { + val vertx = Vertx.vertx() + override fun startServer(port: Int) { + val router = Router.router(vertx).apply { + get("/").handler { request -> + request.response().putHeader("content-type", "text/plain").end("Hello") + } + //get().handler(StaticHandler.create("public")) + } + + val f = CompletableFuture() + vertx.createHttpServer().requestHandler { + router.accept(it) + }.listen(port) { + f.complete(Unit) + } + f.join() + } + + override fun stopServer() { + vertx.close() + } +} \ No newline at end of file