Skip to content

Commit

Permalink
Update bechmarks and fix README
Browse files Browse the repository at this point in the history
  • Loading branch information
eld0727 committed Jul 3, 2019
1 parent 6b7d829 commit 87cf690
Show file tree
Hide file tree
Showing 16 changed files with 11,888 additions and 94 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Specific file types
*.sc
*.class
*.log

# SBT folders
/target
Expand Down
37 changes: 32 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ tethys is a JSON parsing/writing library for Scala
Add dependencies to your `build.sbt`

```scala
val tethysVersion = "0.9.0.1"
val tethysVersion = "0.10.0"
libraryDependecies ++= Seq(
"com.tethys-json" %% "tethys-core" % tethysVersion,
"com.tethys-json" %% "tethys-jackson" % tethysVersion,
Expand All @@ -24,7 +24,7 @@ or just

```scala
libraryDependecies ++= Seq(
"com.tethys-json" %% "tethys" % "0.9.0.1"
"com.tethys-json" %% "tethys" % "0.10.0"
)
```

Expand All @@ -34,6 +34,11 @@ Also, tethys has the following integrations:
```scala
libraryDependencies += "com.tethys-json" %% "tethys-json4s" % tethysVersion
```
#### Enumeratum
[see project page](https://github.com/lloydmeta/enumeratum)
```scala
libraryDependencies += "com.tethys-json" %% "tethys-enumeratum" % tethysVersion
```

# core

Expand Down Expand Up @@ -196,7 +201,6 @@ implicit val fooWriter = jsonWriter[Foo] {
}

implicit val fooReader = jsonReader[Foo] {
describe {
//Any functions are allowed in lambdas
ReaderBuilder[Foo]
.extractReader(_.c).from(_.a)('otherField.as[String]) { // provide reader for Any field
Expand All @@ -206,7 +210,6 @@ implicit val fooReader = jsonReader[Foo] {
}
.extract(_.a).from(_.b).and("otherField2".as[Int])((b, other) => d.toInt + other) // calculate a field that depends on other fields
.extract(_.e).as[Option[Double]](_.getOrElse(1.0)) // extract a field from a value of a specific type
}
}
```

Expand Down Expand Up @@ -253,5 +256,29 @@ val json = """{"bar": 1, "baz": ["some", {"arbitrary": "json"}]"""
val foo = json.jsonAs[Foo].fold(throw _, identity)

foo.bar // 1
foo.baz // JArray(List(JString("some), JObject("arbitrary" -> JString("json"))))
foo.baz // JArray(List(JString("some"), JObject("arbitrary" -> JString("json"))))
```

# enumeratum support

enumeratum module provides bunch of mixins for your Enum classes.
```scala

import enumeratum.{Enum, EnumEntry}
import tethys.enumeratum._

sealed trait Direction extends EnumEntry
case object Direction extends Enum[Direction]
with TethysEnum[Direction] // provides JsonReader and JsonWriter instances
with TethysKeyEnum[Direction] { // provides KeyReader and KeyWriter instances


case object Up extends Direction
case object Down extends Direction
case object Left extends Direction
case object Right extends Direction

val values = findValues
}

```
8 changes: 4 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
lazy val scalaTestVersion = "3.1.0-SNAP13"

lazy val commonSettings = Seq(
version := "0.10.0-SNAPSHOT",
version := "0.10.0",
organization := "com.tethys-json",
scalaVersion := "2.11.12",
crossScalaVersions := Seq("2.11.12", "2.12.8", "2.13.0"),
Expand Down Expand Up @@ -88,7 +88,7 @@ lazy val `jackson-backend` = project.in(file("./modules/jackson-backend"))
.settings(
name := "tethys-jackson",
libraryDependencies ++= Seq(
"com.fasterxml.jackson.core" % "jackson-core" % "2.9.1",
"com.fasterxml.jackson.core" % "jackson-core" % "2.9.9",

"org.scalatest" %% "scalatest" % scalaTestVersion % Test
)
Expand Down Expand Up @@ -121,10 +121,10 @@ lazy val benchmarks = project.in(file("./modules/benchmarks"))
.settings(
publishTo := None,
libraryDependencies ++= Seq(
"io.spray" %% "spray-json" % "1.3.3",
"io.spray" %% "spray-json" % "1.3.5",
"org.json4s" %% "json4s-native" % "3.6.7",
"org.json4s" %% "json4s-jackson" % "3.6.7",
"com.typesafe.play" %% "play-json" % "2.7.3",
"com.typesafe.play" %% "play-json" % "2.7.4",
"io.circe" %% "circe-core" % "0.12.0-M1",
"io.circe" %% "circe-generic" % "0.12.0-M1",
"io.circe" %% "circe-jawn" % "0.12.0-M1",
Expand Down
40 changes: 19 additions & 21 deletions modules/benchmarks/README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@

# Parsing

name \ size|10|100|1000|10000|100000
name \ size|128b|1kb|128kb|1mb|32mb
---|---|---|---|---|---
tethys-jackson|26151.191|3000.388|302.027|24.366|2.949
pure-jackson|31502.612|3105.643|331.109|29.249|3.61
circe-jawn|16899.409|1757.162|167.423|18.187|1.191
circe-jackson|4442.562|503.162|51.477|4.508|0.343
json4s-jackson|4783.177|584.713|59.856|4.736|0.375
json4s-native|4565.986|472.484|38.631|2.702|0.061
play-json|8097.424|802.017|90.829|6.715|0.5
spray-json|13909.521|1461.049|143.485|13.54|1.09
pushka|17011.93|1793.742|172.93|17.379|1.482
tethys-jackson|658951.389|94736.726|733.012|75.496|2.074
pure-jackson|605937.562|105919.836|868.511|95.066|1.929
circe-jawn|500633.274|66962.275|498.646|51.116|0.237
circe-jackson|176264.381|25799.317|151.52|16.372|0.089
json4s-jackson|81864.174|12649.038|89.053|10.534|0.067
json4s-native|77152.505|11726.397|80.094|9.209|0.034
play-json|214148.365|28851.521|186.734|17.297|0.081
spray-json|351719.553|47149.179|347.749|36.3|0.345

![ParsingPerformance](./images/ParsingPerformance.png)

Expand All @@ -20,18 +19,17 @@ pushka|17011.93|1793.742|172.93|17.379|1.482

# Writing

name \ size|10|100|1000|10000|100000
name \ size|128b|1kb|128kb|1mb|32mb
---|---|---|---|---|---
tethys-jackson|80050.495|8080.388|781.19|59.795|5.256
pure-jackson|60366.95|7881.735|762.444|53.371|5.383
circe|26454.325|2624.433|219.181|18.68|1.76
java.lang.StringBuilder|59123.466|6965.116|613.214|47.91|4.807
scala.StringBuilder|56192.622|6411.235|601.54|51.841|4.768
json4s-jackson|6041.135|673.173|68.802|6.143|0.556
json4s-native|8167.998|878.273|85.061|9.145|0.828
play-json|5254.174|625.363|60.902|5.524|0.482
spray-json|18381.438|1745.193|142.44|14.07|1.234
pushka|17759.173|1921.791|162.733|15.325|1.345
tethys-jackson|933624.586|220229.694|1641.102|205.924|3.484
pure-jackson|563304.441|179625.306|1876.364|220.472|4.014
circe|621310.962|86294.08|616.222|56.9|0.801
java.lang.StringBuilder|1365829.788|197955.272|1527.102|167.981|4.629
scala.StringBuilder|1288411.486|196492.325|1531.357|155.445|4.544
json4s-jackson|185964.967|24597.714|178.298|20.374|0.377
json4s-native|197545.065|25536.414|194.544|21.216|0.728
play-json|197279.434|27718.526|208.257|22.433|0.489
spray-json|409063.537|54303.176|384.963|39.317|0.54

![WritingPerformance](./images/WritingPerformance.png)

Expand Down
Binary file modified modules/benchmarks/images/ParsingPerformance.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified modules/benchmarks/images/WritingPerformance.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 87cf690

Please sign in to comment.