Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ package benchmark
import org.openjdk.jmh.annotations._
import org.openjdk.jmh.infra.Blackhole
import java.util.concurrent.TimeUnit

import java.nio.charset.StandardCharsets
import com.google.common.io.Resources
import java.nio.file.{Files, Path}

import com.gu.contentapi.client.model.v1._
import com.gu.contentapi.json.CirceDecoders._
Expand All @@ -31,7 +29,7 @@ case class WrappedLegacyResponse(response: SearchResp)
class JsonDecodeBenchmark {

def loadJson(filename: String): Json = {
val rawJson = Resources.toString(Resources.getResource(filename), StandardCharsets.UTF_8)
val rawJson = Files.readString(Path.of(s"benchmarks/src/main/resources/$filename"))
val circeJson = {
import io.circe.jawn._
parse(rawJson).fold(_ => Json.Null, identity)
Expand Down
3 changes: 0 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ val fezziwigVersion = "2.0.1"

// dependency versions (for tests only)
val scalaTestVersion = "3.2.20"
val guavaVersion = "19.0"
val diffsonVersion = "4.7.0"

// support non-production release types
Expand Down Expand Up @@ -121,7 +120,6 @@ lazy val json = Project(id = "content-api-models-json", base = file("json"))
"io.circe" %% "circe-parser" % circeVersion,
"io.circe" %% "circe-optics" % circeVersion,
"org.scalatest" %% "scalatest" % scalaTestVersion % Test,
"com.google.guava" % "guava" % guavaVersion % Test,
"org.gnieh" %% "diffson-circe" % diffsonVersion % Test
),
Compile / packageDoc / mappings := Nil
Expand All @@ -132,7 +130,6 @@ lazy val benchmarks = Project(id = "benchmarks", base = file("benchmarks"))
.settings(artifactProductionSettings)
.enablePlugins(JmhPlugin)
.settings(
libraryDependencies += "com.google.guava" % "guava" % "19.0",
Jmh / javaOptions ++= Seq("-server", "-Xms4G", "-Xmx4G", "-XX:+UseG1GC", "-XX:-UseBiasedLocking"),
publishArtifact := false
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package com.gu.contentapi.json.utils

import java.nio.charset.StandardCharsets
import com.google.common.io.Resources
import java.nio.file.{Files, Path}
import io.circe.{Decoder, Json}
import io.circe.parser._
import cats.syntax.either._


object JsonHelpers {
def loadJson(filename: String): String = {
Resources.toString(Resources.getResource(s"templates/$filename"), StandardCharsets.UTF_8)
Files.readString(Path.of(s"json/src/test/resources/templates/$filename"))
}

def parseJson[T : Decoder](rawJson: String): T = {
Expand Down
Loading