Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace Play-JSON by jsoniter-scala #5

Merged
merged 2 commits into from
Jul 1, 2020
Merged
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
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
───────╚═╝║ ╚╗║╚═╝║
```

Evaluation of [Play](https://github.com/playframework/playframework) 2.6 API and performance using
Evaluation of [Play](https://github.com/playframework/playframework) 2.8 API and performance using
[Wrk 2](https://github.com/giltene/wrk2).

This project provides examples how to test simplest request and configure server side for better response times and minimal CPU usage:
Expand All @@ -22,37 +22,37 @@ sed -i -e 's/1.6/1/g' ./target/universal/stage/bin/play

### Run the server

- JDK 8:
- Corretto 8:
```sh
export JAVA_HOME=/usr/lib/jvm/java-8-oracle
export JAVA_HOME=/usr/lib/jvm/corretto-8
export JAVA_OPTS="-server -Xms2g -Xmx2g -XX:NewSize=1g -XX:MaxNewSize=1g -XX:+UseParallelGC -XX:-UseBiasedLocking -XX:+AlwaysPreTouch"
./target/universal/stage/bin/play
```

- JDK 10:
- OpenJDK 16:
```sh
export JAVA_HOME=/usr/lib/jvm/jdk-10
export JAVA_HOME=/usr/lib/jvm/openjdk-16
export JAVA_OPTS="-server -Xms2g -Xmx2g -XX:NewSize=1g -XX:MaxNewSize=1g -XX:+UseParallelGC -XX:-UseBiasedLocking -XX:+AlwaysPreTouch"
./target/universal/stage/bin/play
```

- JDK 10 + Graal:
- OpenJDK 10 + Graal:
```sh
export JAVA_HOME=/usr/lib/jvm/jdk-10
export JAVA_HOME=/usr/lib/jvm/openjdk-16
export JAVA_OPTS="-server -Xms2g -Xmx2g -XX:NewSize=1g -XX:MaxNewSize=1g -XX:+UseParallelGC -XX:-UseBiasedLocking -XX:+AlwaysPreTouch -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:+UseJVMCICompiler"
./target/universal/stage/bin/play
```

- GraalVM CE:
- GraalVM CE Java 8:
```sh
export JAVA_HOME=/usr/lib/jvm/graalvm-ce-1.0.0-rc1
export JAVA_HOME=/usr/lib/jvm/graalvm-ce-java8
export JAVA_OPTS="-server -Xms2g -Xmx2g -XX:NewSize=1g -XX:MaxNewSize=1g -XX:+UseParallelGC -XX:-UseBiasedLocking -XX:+AlwaysPreTouch"
./target/universal/stage/bin/play
```

- GraalVM EE:
- GraalVM EE Java 8:
```sh
export JAVA_HOME=/usr/lib/jvm/graalvm-ee-1.0.0-rc1
export JAVA_HOME=/usr/lib/jvm/graalvm-ee-java8
export JAVA_OPTS="-server -Xms2g -Xmx2g -XX:NewSize=1g -XX:MaxNewSize=1g -XX:+UseParallelGC -XX:-UseBiasedLocking -XX:+AlwaysPreTouch"
./target/universal/stage/bin/play
```
Expand Down
8 changes: 4 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
name := "play"
organization := "com.github.plokhotnyuk"
version := "1.0-SNAPSHOT"
scalaVersion := "2.12.6"
scalaVersion := "2.13.3"
val root = (project in file("."))
.enablePlugins(PlayScala, PlayNettyServer)
.disablePlugins(PlayAkkaHttpServer)
.disablePlugins(PlayLayoutPlugin)
libraryDependencies ++= Seq(
guice,
"com.github.plokhotnyuk.jsoniter-scala" %% "jsoniter-scala-core" % "0.29.16",
"com.github.plokhotnyuk.jsoniter-scala" %% "jsoniter-scala-macros" % "0.29.16",
"com.typesafe.play" %% "play-ws" % "2.6.13"
"com.github.plokhotnyuk.jsoniter-scala" %% "jsoniter-scala-core" % "2.4.4",
"com.github.plokhotnyuk.jsoniter-scala" %% "jsoniter-scala-macros" % "2.4.4" % "compile-internal",
"com.typesafe.play" %% "play-ws" % "2.8.2"
)
javaOptions := Seq(
"-server",
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.2.1
sbt.version=1.3.12
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
logLevel := Level.Warn

addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.6.13")
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.2")
3 changes: 2 additions & 1 deletion src/main/scala/microservice/HelloWorldController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import scala.concurrent.{ExecutionContext, Future}
@Singleton
class HelloWorldController @Inject() (components: ControllerComponents)
(implicit ec: ExecutionContext) extends AbstractController(components) {
import com.github.plokhotnyuk.jsoniter_scala.core.{writeToArray, readFromArray}
import com.github.plokhotnyuk.jsoniter_scala.core._
import microservice.JsoniterScalaCodecs._

val jsonGet: Action[AnyContent] = components.actionBuilder.async {
Future(Ok(ByteString.fromArrayUnsafe(writeToArray(HelloWorld("Hello, World!")))))
Expand Down
8 changes: 8 additions & 0 deletions src/main/scala/microservice/JsoniterScalaCodecs.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package microservice

import com.github.plokhotnyuk.jsoniter_scala.core._
import com.github.plokhotnyuk.jsoniter_scala.macros._

object JsoniterScalaCodecs {
implicit val helloWorldCodec: JsonValueCodec[HelloWorld] = JsonCodecMaker.make[HelloWorld]
}