-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Greg Zoller
committed
Nov 14, 2023
1 parent
e48b358
commit ee5da35
Showing
42 changed files
with
2,798 additions
and
374 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,27 @@ | ||
package co.blocke | ||
|
||
import argonaut._, Argonaut._ | ||
import org.openjdk.jmh.annotations._ | ||
|
||
|
||
implicit val CodecPet: CodecJson[Pet] = | ||
casecodec3(Pet.apply, (a: Pet) => Option((a.name, a.species, a.age)))("name","species","age") | ||
object ArgonautZ: | ||
import argonaut._, Argonaut._ | ||
|
||
implicit val CodecFriend: CodecJson[Friend] = | ||
casecodec3(Friend.apply, (a: Friend) => Option((a.name, a.age, a.email)))("name","age","email") | ||
implicit val CodecPet: CodecJson[Pet] = | ||
casecodec3(Pet.apply, (a: Pet) => Option((a.name, a.species, a.age)))("name","species","age") | ||
|
||
implicit val CodecAddress: CodecJson[Address] = | ||
casecodec4(Address.apply, (a: Address) => Option((a.street, a.city, a.state, a.postal_code)))("street","city","state","postal_code") | ||
implicit val CodecFriend: CodecJson[Friend] = | ||
casecodec3(Friend.apply, (a: Friend) => Option((a.name, a.age, a.email)))("name","age","email") | ||
|
||
implicit val CodecPerson: CodecJson[Person] = | ||
casecodec6(Person.apply, (a: Person) => Option((a.name, a.age, a.address, a.email, a.phone_numbers, a.is_employed)))("name", "age","address","email","phone_numbers","is_employed") | ||
implicit val CodecAddress: CodecJson[Address] = | ||
casecodec4(Address.apply, (a: Address) => Option((a.street, a.city, a.state, a.postal_code)))("street","city","state","postal_code") | ||
|
||
implicit val CodecRecord: CodecJson[Record] = | ||
casecodec4(Record.apply, (a: Record) => Option((a.person, a.hobbies, a.friends, a.pets)))("person", "hobbies", "friends", "pets") | ||
implicit val CodecPerson: CodecJson[Person] = | ||
casecodec6(Person.apply, (a: Person) => Option((a.name, a.age, a.address, a.email, a.phone_numbers, a.is_employed)))("name", "age","address","email","phone_numbers","is_employed") | ||
|
||
implicit val CodecRecord: CodecJson[Record] = | ||
casecodec4(Record.apply, (a: Record) => Option((a.person, a.hobbies, a.friends, a.pets)))("person", "hobbies", "friends", "pets") | ||
|
||
trait ArgonautWritingBenchmark { | ||
@Benchmark | ||
def writeRecordArgonaut = record.asJson | ||
} | ||
trait ArgonautWritingBenchmark { | ||
@Benchmark | ||
def writeRecordArgonaut = record.asJson | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package co.blocke | ||
|
||
import org.openjdk.jmh.annotations._ | ||
|
||
object CirceZ: | ||
import io.circe.syntax.* | ||
import io.circe.* | ||
import io.circe.generic.semiauto.* | ||
import io.circe.parser.* | ||
|
||
implicit val recordDecoder: Decoder[Record] = deriveDecoder[Record] | ||
implicit val recordEncoder: Encoder[Record] = deriveEncoder[Record] | ||
|
||
implicit val personDecoder: Decoder[Person] = deriveDecoder[Person] | ||
implicit val personEncoder: Encoder[Person] = deriveEncoder[Person] | ||
|
||
implicit val addressDecoder: Decoder[Address] = deriveDecoder[Address] | ||
implicit val addressEncoder: Encoder[Address] = deriveEncoder[Address] | ||
|
||
implicit val friendDecoder: Decoder[Friend] = deriveDecoder[Friend] | ||
implicit val friendEncoder: Encoder[Friend] = deriveEncoder[Friend] | ||
|
||
implicit val petDecoder: Decoder[Pet] = deriveDecoder[Pet] | ||
implicit val petEncoder: Encoder[Pet] = deriveEncoder[Pet] | ||
|
||
trait CirceReadingBenchmark{ | ||
@Benchmark | ||
def readRecordCirce = parse(jsData).flatMap(_.as[Record]) | ||
} | ||
|
||
trait CirceWritingBenchmark { | ||
@Benchmark | ||
def writeRecordCirce = record.asJson | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package co.blocke | ||
|
||
import org.openjdk.jmh.annotations._ | ||
|
||
object FabricZ: | ||
import fabric.* | ||
import fabric.io.* | ||
|
||
trait FabricReadingBenchmark{ | ||
@Benchmark | ||
def readRecordFabric = JsonParser(jsData, Format.Json) | ||
} | ||
|
||
// trait CirceWritingBenchmark { | ||
// @Benchmark | ||
// def writeRecordCirce = record.asJson | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package co.blocke | ||
|
||
import org.openjdk.jmh.annotations._ | ||
|
||
object JawnZ: | ||
|
||
import org.typelevel.jawn.ast.* | ||
|
||
trait JawnReadingBenchmark{ | ||
@Benchmark | ||
def readRecordFabric = JParser.parseFromString(jsData) | ||
} | ||
|
||
// trait CirceWritingBenchmark { | ||
// @Benchmark | ||
// def writeRecordCirce = record.asJson | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,60 @@ | ||
package co.blocke | ||
|
||
import play.api.libs.json._ | ||
import play.api.libs.json.Reads._ | ||
import play.api.libs.functional.syntax._ | ||
import org.openjdk.jmh.annotations._ | ||
|
||
implicit val friendWrites: Writes[Friend] = ( | ||
(JsPath \ "name").write[String] and | ||
(JsPath \ "age").write[Int] and | ||
(JsPath \ "email").write[String] | ||
)(unlift((a: Friend) => Option((a.name, a.age, a.email)))) | ||
|
||
implicit val petWrites: Writes[Pet] = ( | ||
(JsPath \ "name").write[String] and | ||
(JsPath \ "species").write[String] and | ||
(JsPath \ "age").write[Int] | ||
)(unlift((a: Pet) => Option((a.name, a.species, a.age)))) | ||
|
||
implicit val addressWrites: Writes[Address] = ( | ||
(JsPath \ "street").write[String] and | ||
(JsPath \ "city").write[String] and | ||
(JsPath \ "state").write[String] and | ||
(JsPath \ "postal_code").write[String] | ||
)(unlift((a: Address) => Option((a.street, a.city, a.state, a.postal_code)))) | ||
|
||
implicit val personWrites: Writes[Person] = ( | ||
(JsPath \ "namet").write[String] and | ||
(JsPath \ "age").write[Int] and | ||
(JsPath \ "address").write[Address] and | ||
(JsPath \ "email").write[String] and | ||
(JsPath \ "phone_numbers").write[List[String]] and | ||
(JsPath \ "is_employed").write[Boolean] | ||
)(unlift((a: Person) => Option((a.name, a.age, a.address, a.email, a.phone_numbers, a.is_employed)))) | ||
|
||
implicit val recordWrites: Writes[Record] = ( | ||
(JsPath \ "person").write[Person] and | ||
(JsPath \ "hobbies").write[List[String]] and | ||
(JsPath \ "friends").write[List[Friend]] and | ||
(JsPath \ "pets").write[List[Pet]] | ||
)(unlift((a: Record) => Option((a.person, a.hobbies, a.friends, a.pets)))) | ||
|
||
trait PlayWritingBenchmark { | ||
@Benchmark | ||
def writeRecordPlay = Json.toJson(record) | ||
} | ||
object PlayZ: | ||
import play.api.libs.json._ | ||
import play.api.libs.json.Reads._ | ||
import play.api.libs.functional.syntax._ | ||
|
||
implicit val friendWrites: Writes[Friend] = ( | ||
(JsPath \ "name").write[String] and | ||
(JsPath \ "age").write[Int] and | ||
(JsPath \ "email").write[String] | ||
)(unlift((a: Friend) => Option((a.name, a.age, a.email)))) | ||
|
||
implicit val petWrites: Writes[Pet] = ( | ||
(JsPath \ "name").write[String] and | ||
(JsPath \ "species").write[String] and | ||
(JsPath \ "age").write[Int] | ||
)(unlift((a: Pet) => Option((a.name, a.species, a.age)))) | ||
|
||
implicit val addressWrites: Writes[Address] = ( | ||
(JsPath \ "street").write[String] and | ||
(JsPath \ "city").write[String] and | ||
(JsPath \ "state").write[String] and | ||
(JsPath \ "postal_code").write[String] | ||
)(unlift((a: Address) => Option((a.street, a.city, a.state, a.postal_code)))) | ||
|
||
implicit val personWrites: Writes[Person] = ( | ||
(JsPath \ "namet").write[String] and | ||
(JsPath \ "age").write[Int] and | ||
(JsPath \ "address").write[Address] and | ||
(JsPath \ "email").write[String] and | ||
(JsPath \ "phone_numbers").write[List[String]] and | ||
(JsPath \ "is_employed").write[Boolean] | ||
)(unlift((a: Person) => Option((a.name, a.age, a.address, a.email, a.phone_numbers, a.is_employed)))) | ||
|
||
implicit val recordWrites: Writes[Record] = ( | ||
(JsPath \ "person").write[Person] and | ||
(JsPath \ "hobbies").write[List[String]] and | ||
(JsPath \ "friends").write[List[Friend]] and | ||
(JsPath \ "pets").write[List[Pet]] | ||
)(unlift((a: Record) => Option((a.person, a.hobbies, a.friends, a.pets)))) | ||
|
||
implicit val friendReads: play.api.libs.json.Reads[co.blocke.Friend] = Json.reads[Friend] | ||
implicit val petReads: play.api.libs.json.Reads[co.blocke.Pet] = Json.reads[Pet] | ||
implicit val addressReads: play.api.libs.json.Reads[co.blocke.Address] = Json.reads[Address] | ||
implicit val personReads: play.api.libs.json.Reads[co.blocke.Person] = Json.reads[Person] | ||
implicit val recordReads: play.api.libs.json.Reads[co.blocke.Record] = Json.reads[Record] | ||
|
||
trait PlayWritingBenchmark { | ||
@Benchmark | ||
def writeRecordPlay = Json.toJson(record) | ||
} | ||
|
||
// val playJS = Json.toJson(record) | ||
trait PlayReadingBenchmark { | ||
@Benchmark | ||
def readRecordPlay = Json.fromJson[Record](Json.parse(jsData)) //Json.fromJson[Record](playJS) | ||
} |
Oops, something went wrong.