Skip to content

Commit 4b0ad30

Browse files
tekumaramichaelhixson
authored andcommitted
add cask (#4010)
1 parent 5ee28b6 commit 4b0ad30

File tree

8 files changed

+109
-0
lines changed

8 files changed

+109
-0
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ env:
8080
- "TESTDIR=Java/wicket"
8181
- "TESTDIR=Java/wildfly-ee7"
8282
- "TESTDIR=Java/wizzardo-http"
83+
- "TESTDIR=Scala/cask"
8384
- "TESTLANG=JavaScript"
8485
- "TESTLANG=Kotlin"
8586
- "TESTLANG=Lua"

frameworks/Scala/cask/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# cask Benchmarking Test
2+
3+
### Test Type Implementation Source Code
4+
5+
* [JSON](src/main/scala/example/Main.scala)
6+
* [PLAINTEXT](src/main/scala/example/Main.scala)
7+
8+
## Important Libraries
9+
The tests were run with:
10+
* [cask](https://github.com/lihaoyi/cask)
11+
* [jsoniter-scala](https://github.com/plokhotnyuk/jsoniter-scala)
12+
13+
## Test URLs
14+
### JSON
15+
16+
http://localhost:8080/json
17+
18+
### PLAINTEXT
19+
20+
http://localhost:8080/plaintext
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"framework": "cask",
3+
"tests": [
4+
{
5+
"default": {
6+
"json_url": "/json",
7+
"plaintext_url": "/plaintext",
8+
"port": 8080,
9+
"approach": "Realistic",
10+
"classification": "Micro",
11+
"database": "None",
12+
"framework": "cask",
13+
"language": "Scala",
14+
"flavor": "None",
15+
"orm": "None",
16+
"platform": "Undertow",
17+
"webserver": "None",
18+
"os": "Linux",
19+
"database_os": "Linux",
20+
"display_name": "cask",
21+
"notes": "",
22+
"versus": "Undertow"
23+
}
24+
}
25+
]
26+
}

frameworks/Scala/cask/build.sbt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name := """cask-example"""
2+
3+
version := "1.0"
4+
5+
scalaVersion := "2.12.5"
6+
7+
libraryDependencies ++= Seq(
8+
"com.lihaoyi" %% "cask" % "0.1.1",
9+
"com.github.plokhotnyuk.jsoniter-scala" %% "macros" % "0.21.6"
10+
)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM hseeberger/scala-sbt:8u151-2.12.5-1.1.2
2+
WORKDIR /cask
3+
COPY project project
4+
COPY src src
5+
COPY build.sbt build.sbt
6+
RUN sbt assembly -batch
7+
CMD ["java", "-server", "-Xms1g", "-Xmx1g", "-XX:NewSize=512m", "-XX:MaxNewSize=512m", "-XX:+UseParallelGC", "-XX:+AggressiveOpts", "-XX:+UseNUMA", "-XX:-UseBiasedLocking", "-XX:+AlwaysPreTouch", "-jar", "target/scala-2.12/cask-example-assembly-1.0.jar"]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sbt.version=1.1.2
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.6")
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package example
2+
3+
import com.github.plokhotnyuk.jsoniter_scala.core._
4+
import com.github.plokhotnyuk.jsoniter_scala.macros._
5+
import io.undertow.{Undertow, UndertowOptions}
6+
7+
case class Message(message: String)
8+
9+
object Main extends cask.MainRoutes {
10+
11+
implicit val codec: JsonValueCodec[Message] = JsonCodecMaker.make[Message](CodecMakerConfig())
12+
13+
override def main(args: Array[String]): Unit = {
14+
val server = Undertow.builder
15+
.addHttpListener(8080, "0.0.0.0")
16+
// increase io thread count as per https://github.com/TechEmpower/FrameworkBenchmarks/pull/4008
17+
.setIoThreads(Runtime.getRuntime().availableProcessors() * 2)
18+
// In HTTP/1.1, connections are persistent unless declared otherwise.
19+
// Adding a "Connection: keep-alive" header to every response would only
20+
// add useless bytes.
21+
.setServerOption[java.lang.Boolean](UndertowOptions.ALWAYS_SET_KEEP_ALIVE, false)
22+
.setHandler(defaultHandler)
23+
.build
24+
server.start()
25+
}
26+
27+
@cask.get("/plaintext")
28+
def plaintext() = {
29+
cask.Response(data = "Hello, World!",
30+
headers = Seq("Server" -> "cask", "Content-Type" -> "text/plain")
31+
)
32+
33+
}
34+
35+
@cask.get("/json")
36+
def json(request: cask.Request) = {
37+
cask.Response(data = writeToArray(Message("Hello, World!")),
38+
headers = Seq("Server" -> "cask", "Content-Type" -> "application/json")
39+
)
40+
}
41+
42+
initialize()
43+
}

0 commit comments

Comments
 (0)