org.openjdk.jmh.annotations.Benchmark Scala Examples
The following examples show how to use org.openjdk.jmh.annotations.Benchmark.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
Example 1
Source File: CirceRunners.scala From boopickle with Apache License 2.0 | 5 votes |
package boopickle.perftests import java.nio.charset.StandardCharsets import io.circe._ import io.circe.syntax._ import io.circe.parser._ import io.circe.generic.semiauto._ import org.openjdk.jmh.annotations.Benchmark abstract class CirceRunner[A](data: A) extends TestRunner[A](data) { override def name = "Circe" } object CirceRunners { def encodeRunner[A](data: A)(implicit p: Encoder[A], u: Decoder[A]): CirceRunner[A] = new CirceRunner[A](data) { var testData: A = _ override def initialize = { testData = data val res = testData.asJson.noSpaces res.getBytes(StandardCharsets.UTF_8) } override def run(): Any = { testData.asJson.noSpaces () } } def decodeRunner[A](data: A)(implicit p: Encoder[A], u: Decoder[A]): CirceRunner[A] = new CirceRunner[A](data) { var testData: A = _ var s: String = _ override def initialize = { testData = data s = testData.asJson.noSpaces s.getBytes(StandardCharsets.UTF_8) } override def run(): Any = { u.decodeJson(parser.parse(s).toOption.get) () } } } trait CirceCoding { self: TestData => private implicit val eventEncoder: Encoder[Event] = deriveEncoder[Event] private lazy val eventDecoder = deriveDecoder[Event] private lazy val eventJson = event.asJson.noSpaces private lazy val intsJson = largeIntSeq.asJson.noSpaces private lazy val doublesJson = largeDoubleSeq.asJson.noSpaces @Benchmark def circeEventDecode: Event = { eventDecoder.decodeJson(parse(eventJson).right.get).right.get } @Benchmark def circeEventEncode: String = { eventEncoder(event).noSpaces } @Benchmark def circeIntArrayDecode: Array[Int] = { decode[Array[Int]](intsJson).right.get } @Benchmark def circeIntArrayEncode: String = { largeIntSeq.asJson.noSpaces } @Benchmark def circeDoubleArrayDecode: Array[Double] = { decode[Array[Double]](doublesJson).right.get } @Benchmark def circeDoubleArrayEncode: String = { largeDoubleSeq.asJson.noSpaces } }
Example 2
Source File: RandomUtilBenchmarks.scala From aerosolve with Apache License 2.0 | 5 votes |
package com.airbnb.common.ml.util import scala.collection.mutable import org.openjdk.jmh.annotations.Benchmark import org.openjdk.jmh.annotations.BenchmarkMode import org.openjdk.jmh.annotations.Fork import org.openjdk.jmh.annotations.Measurement import org.openjdk.jmh.annotations.Mode import org.openjdk.jmh.annotations.Param import org.openjdk.jmh.annotations.Scope import org.openjdk.jmh.annotations.State import org.openjdk.jmh.annotations.Warmup object RandomUtilBenchmarks { @BenchmarkMode(Array(Mode.Throughput)) @Fork(value = 1, warmups = 0) @Warmup(iterations = 4, time = 2) @Measurement(iterations = 8, time = 2) @State(value = Scope.Benchmark) class SampleBenchmarks { // Try different collection sizes @Param(value = Array("1000", "10000")) var numItemsToGenerate: Int = _ val ratios: Seq[Double] = Seq(0.85, 0.1, 0.05) @Benchmark def sampleArray(): Seq[Seq[Int]] = { RandomUtil.sample( Array.range(1, numItemsToGenerate), ratios ) } @Benchmark def sampleArraySeq(): Seq[Seq[Int]] = { RandomUtil.sample( mutable.ArraySeq.range(1, numItemsToGenerate), ratios ) } @Benchmark def sampleList(): Seq[Seq[Int]] = { RandomUtil.sample( List.range(1, numItemsToGenerate), ratios ) } @Benchmark def sampleSeq(): Seq[Seq[Int]] = { RandomUtil.sample( Seq.range(1, numItemsToGenerate), ratios ) } @Benchmark def sampleVector(): Seq[Seq[Int]] = { RandomUtil.sample( Vector.range(1, numItemsToGenerate), ratios ) } @Benchmark def sampleSeqToVector(): Seq[Seq[Int]] = { RandomUtil.sample( Seq.range(1, numItemsToGenerate).toVector, ratios ) } } }
Example 3
Source File: CornichonJsonBench.scala From cornichon with Apache License 2.0 | 5 votes |
package parsers import cats.instances.string._ import com.github.agourlay.cornichon.json.CornichonJson import org.openjdk.jmh.annotations.{ Benchmark, BenchmarkMode, Fork, Measurement, Mode, Scope, State, Warmup } @State(Scope.Benchmark) @BenchmarkMode(Array(Mode.Throughput)) @Warmup(iterations = 10) @Measurement(iterations = 10) @Fork(value = 1, jvmArgsAppend = Array( "-XX:+FlightRecorder", "-XX:StartFlightRecording=filename=./CornichonJSonBench-profiling-data.jfr,name=profile,settings=profile", "-Xmx1G")) class CornichonJsonBench { @Benchmark def parseDslStringJsonString() = { val res = CornichonJson.parseDslJson("cornichon") assert(res.isRight) } @Benchmark def parseDslStringJsonArray() = { val res = CornichonJson.parseDslJson("""[ "cornichon", "cornichon" ] """) assert(res.isRight) } @Benchmark def parseDslStringJsonTable() = { val res = CornichonJson.parseDslJson(""" Name | Age | "John" | 30 | "Bob" | 41 | """) assert(res.isRight) } }
Example 4
Source File: StringBuilderBenchmark.scala From scala-string-format with MIT License | 5 votes |
package com.komanov.stringformat.jmh import org.openjdk.jmh.annotations.Benchmark class StringBuilderBenchmark extends BenchmarkBase { @Benchmark def javaStringBuilder: String = { new java.lang.StringBuilder() .append("abc") .append("def") .toString } @Benchmark def javaStringBuilder2: String = { new java.lang.StringBuilder() .append("string______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________495") .append("string______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________495") .toString } @Benchmark def scalaStringBuilder: String = { new scala.collection.mutable.StringBuilder() .append("abc") .append("def") .toString } @Benchmark def scalaStringBuilder2: String = { new scala.collection.mutable.StringBuilder() .append("string______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________495") .append("string______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________495") .toString } }
Example 5
Source File: SimpleBenchmarks.scala From scala-string-format with MIT License | 5 votes |
package com.komanov.stringformat.jmh import org.openjdk.jmh.annotations.Benchmark class EmptyStringBenchmark extends BenchmarkBase { @Benchmark def baseline: String = { "" } @Benchmark def sInterpolator: String = { s"" } @Benchmark def sfiInterpolator: String = { import com.komanov.stringformat.macros.MacroConcat._ sfi"" } } class ConstStringBenchmark extends BenchmarkBase { @Benchmark def baseline: String = { "abc" } @Benchmark def sInterpolator: String = { s"abc" } @Benchmark def sfiInterpolator: String = { import com.komanov.stringformat.macros.MacroConcat._ sfi"abc" } }
Example 6
Source File: NewStringBenchmark.scala From scala-string-format with MIT License | 5 votes |
package com.komanov.stringformat.jmh import com.komanov.stringformat.FastStringFactory import org.openjdk.jmh.annotations.Benchmark object NewStringBenchmarkData { val chars = new Array[Char](1006) val sb = new java.lang.StringBuilder(chars.length) .append(chars) } class NewStringBenchmark extends BenchmarkBase { @Benchmark def baseline: String = { "" } @Benchmark def newString: String = { new String(NewStringBenchmarkData.chars) } @Benchmark def fastString: String = { FastStringFactory.fastNewString(NewStringBenchmarkData.chars) } @Benchmark def sbToString: String = { NewStringBenchmarkData.sb.toString } @Benchmark def fastSb: String = { FastStringFactory.fastNewString(NewStringBenchmarkData.sb) } }
Example 7
Source File: UnsafeBitArrayBenchmark.scala From bloom-filter-scala with MIT License | 5 votes |
package bloomfilter import java.util.BitSet import bloomfilter.mutable.UnsafeBitArray import org.openjdk.jmh.annotations.{Benchmark, Scope, State} import sandbox.bloomfilter.mutable.ChronicleBitArray @State(Scope.Benchmark) class UnsafeBitArrayBenchmark { private val numberOfBits = Int.MaxValue val unsafeBits = new UnsafeBitArray(numberOfBits.toLong) val bitsSet = new BitSet(numberOfBits) val chronicle = new ChronicleBitArray(numberOfBits.toLong) @Benchmark def getUnsafe() = { unsafeBits.get(1) unsafeBits.get(10) unsafeBits.get(100) unsafeBits.get(1000) unsafeBits.get(10000) unsafeBits.get(100000) unsafeBits.get(1000000) } @Benchmark def getBitSet() = { bitsSet.get(1) bitsSet.get(10) bitsSet.get(100) bitsSet.get(1000) bitsSet.get(10000) bitsSet.get(100000) bitsSet.get(1000000) } @Benchmark def getChronicle() = { chronicle.get(1) chronicle.get(10) chronicle.get(100) chronicle.get(1000) chronicle.get(10000) chronicle.get(100000) chronicle.get(1000000) } }
Example 8
Source File: MurmurHash3GenericBenchmark.scala From bloom-filter-scala with MIT License | 5 votes |
package bloomfilter.hashing import org.openjdk.jmh.annotations.{Benchmark, Scope, State} import sandbox.hashing.MurmurHash3 @State(Scope.Benchmark) class MurmurHash3GenericBenchmark { val key = Range(0, 64).map(_.toByte).toArray @Benchmark def scalaVersion() = { MurmurHash3.murmurhash3_x64_128(key, 0, key.length, 0) } @Benchmark def genericVersion() = { MurmurHash3Generic.murmurhash3_x64_128(key, 0, key.length, 0) } }
Example 9
Source File: MurmurHash3Benchmark.scala From bloom-filter-scala with MIT License | 5 votes |
package bloomfilter.hashing import java.nio.ByteBuffer import sandbox.hashing.{YonikMurmurHash3, CassandraMurmurHash, AlgebirdMurmurHash128} import sandbox.hashing.YonikMurmurHash3.LongPair import com.yahoo.sketches.hash.{MurmurHash3 => yMurmurHash3} import com.google.common.hash.Hashing import org.openjdk.jmh.annotations.{Benchmark, Scope, State} import scala.util.hashing.{MurmurHash3 => ScalaMurmurHash3} import com.clearspring.analytics.hash.{MurmurHash => StreamLibMurmurHash} @State(Scope.Benchmark) class MurmurHash3Benchmark { val key = Range(0, 64).map(_.toByte).toArray @Benchmark def javaVersion() = { YonikMurmurHash3.murmurhash3_x64_128(key, 0, key.length, 0, new LongPair) } @Benchmark def scalaVersion() = { MurmurHash3Generic.murmurhash3_x64_128(key, 0, key.length, 0) } val guavaMurmur = Hashing.murmur3_128() @Benchmark def guavaVersion() = { guavaMurmur.hashBytes(key, 0, key.length) } @Benchmark def cassandraVersion() = { CassandraMurmurHash.hash3_x64_128(ByteBuffer.wrap(key), 0, key.length, 0) } val algebirdMurmur = AlgebirdMurmurHash128(0) @Benchmark def algebirdVersion() = { algebirdMurmur.apply(key) } @Benchmark def yahooVersion() = { yMurmurHash3.hash(key, 0) } @Benchmark def scalaStdlibVersion() = { ScalaMurmurHash3.arrayHash(key, 0) } @Benchmark def streamLibVersion() = { StreamLibMurmurHash.hash(key) } }
Example 10
Source File: CoproductErrorHandlingBench.scala From hotpotato with Apache License 2.0 | 5 votes |
package hotpotato // Must not be in default package import java.util.concurrent.TimeUnit import org.openjdk.jmh.annotations.{Benchmark, BenchmarkMode, Mode, OutputTimeUnit} import hotpotato.Examples._ import hotpotato.ZioExamples._ import BenchmarkSetup.TracedRuntime @OutputTimeUnit(TimeUnit.MILLISECONDS) @BenchmarkMode(Array(Mode.Throughput)) class CoproductErrorHandlingBench { @Benchmark def copBigMapErrorSome1(): Unit = { val io = b_E1to8_1.mapErrorSome( (_: E1) => MSG, (_: E8) => MSG_8, ) val _ = TracedRuntime.unsafeRun(io.either) } @Benchmark def copBigMapErrorSome8(): Unit = { val io = b_E1to8_8.mapErrorSome( (_: E1) => MSG, (_: E8) => MSG_8, ) val _ = TracedRuntime.unsafeRun(io.either) } }
Example 11
Source File: StringyMapBenchmarks.scala From scalaz-deriving with GNU Lesser General Public License v3.0 | 5 votes |
// Copyright: 2017 - 2020 Sam Halliday // License: http://www.gnu.org/licenses/lgpl-3.0.en.html package jsonformat.benchmarks import jsonformat._ import internal._ import org.openjdk.jmh.annotations.{ Benchmark, Param, Scope, Setup, State } import scalaz._, Scalaz._ // jsonformat/jmh:run -i 5 -wi 5 -f1 -t2 -w1 -r1 StringyMapBenchmarks.* @State(Scope.Benchmark) class StringyMapBenchmarks { @Param(Array("2", "4", "8", "16", "32", "64", "128", "256", "512", "1024")) var size: Int = 0 var data: IList[(String, String)] = _ var queries: IList[String] = IList((size / 2).toString, "<not here>") var stringy_ilist: StringyMap[String] = _ var stringy_java: StringyMap[String] = _ @Setup def setup(): Unit = { data = (0 |-> size).map(i => (i.toString, i.toString)).toIList stringy_ilist = createIList() stringy_java = createJava() } //@Benchmark def createIList(): StringyMap[String] = StringyIList(data) @Benchmark def createJava(): StringyMap[String] = StringyJavaMap(data, 16) @Benchmark def lookupIList(): IList[Maybe[String]] = queries.map(stringy_ilist.get) @Benchmark def lookupJava(): IList[Maybe[String]] = queries.map(stringy_java.get) } // jsonformat/jmh:run -i 1 -wi 1 -f1 -t2 -w1 -r1 StringyMapMoarBenchmarks.* // // jsonformat/jmh:run -i 1 -wi 1 -f1 -t2 -w1 -r1 StringyMapMoarBenchmarks.* -p numEntries=64 -p numQueries=64 @State(Scope.Benchmark) class StringyMapMoarBenchmarks { @Param(Array("1", "2", "4", "8", "16")) var numEntries: Int = 0 @Param(Array("1", "2", "3", "4", "5", "6")) var numQueries: Int = 0 var data: IList[(String, String)] = _ var queries: IList[String] = _ @Setup def setup(): Unit = { data = (0 |-> numEntries).map(i => (i.toString, i.toString)).toIList queries = (0 |-> numQueries).reverse.map(i => i.toString).toIList } @Benchmark def aggregateIList(): IList[Maybe[String]] = { val lookup = StringyIList(data) queries.map(lookup.get) } @Benchmark def aggregateJava(): IList[Maybe[String]] = { val lookup = StringyJavaMap(data, numQueries) queries.map(lookup.get) } }
Example 12
Source File: FieldLookupBenchmarks.scala From scalaz-deriving with GNU Lesser General Public License v3.0 | 5 votes |
// Copyright: 2017 - 2020 Sam Halliday // License: http://www.gnu.org/licenses/lgpl-3.0.en.html package jsonformat.benchmarks import jsonformat._ import jsonformat.BenchmarkUtils.getResourceAsString import org.openjdk.jmh.annotations.{ Benchmark, Scope, Setup, State } import scalaz._, Scalaz._ import JsDecoder.ops._ // jsonformat/jmh:run -i 5 -wi 5 -f1 -t2 -w1 -r1 FieldLookupBenchmarks.* final case class FieldLookup( id: Long ) // when benching magnolia, we seen some strange perf patterns when looking up // fields in the twitter model. My suspicion is that large case classes or // backtick fields have a perf regression. @State(Scope.Benchmark) class FieldLookupBenchmarks { var user: s.User = _ var baseline: FieldLookup = _ @Setup def setup(): Unit = { val raw = getResourceAsString("twitter_api_response.json") val ast = JsParser(raw).getOrElse(null) user = ast.as[List[s.Tweet]].getOrElse(null).head.user baseline = FieldLookup(0) } @Benchmark def fieldAccessBaseline(): Long = baseline.id @Benchmark def elementAccessBaseline(): Long = baseline.productElement(0).asInstanceOf[Long] @Benchmark def fieldAccessPlain(): Long = user.id @Benchmark def elementAccessPlain(): Long = user.productElement(0).asInstanceOf[Long] @Benchmark def fieldAccessBacktick(): Boolean = user.`protected` @Benchmark def elementAccessBacktick(): Boolean = user.productElement(8).asInstanceOf[Boolean] @Benchmark def fieldAccessXl(): String = user.translator_type @Benchmark def elementAccessXl(): String = user.productElement(41).asInstanceOf[String] @Benchmark def indirectionAccessValXl(): String = translator_type_val(user) @Benchmark def indirectionAccessDefXl(): String = translator_type_def(user) @Benchmark def indirectionAccessDefValXl(): String = translator_type_abstract(user, translator_type_val) @Benchmark def indirectionAccessDefDefXl(): String = translator_type_abstract(user, translator_type_def) val translator_type_val = (u: s.User) => u.translator_type def translator_type_def(u: s.User) = u.translator_type def translator_type_abstract(u: s.User, f: s.User => String): String = f(u) }
Example 13
Source File: FreeMonads.scala From scato with Apache License 2.0 | 5 votes |
package scato package benchmarks import scala.annotation.tailrec import org.openjdk.jmh.annotations.{Benchmark, BenchmarkMode, Fork, Mode} @Fork(1) @BenchmarkMode(Array(Mode.Throughput)) class FreeMonads { def runScato(size: Int) = { import transformers.State import FreeMonadsScato._ run(mkFreeT[State[Int, ?]](size)) } def runScalaz(size: Int): Int = { import FreeMonadsScalaz._ run(mkFree(size)) } @Benchmark def free128Scato = runScato(128) @Benchmark def free128Scalaz = runScalaz(128) @Benchmark def free1024Scato = runScato(1024) @Benchmark def free1024Scalaz = runScalaz(1024) @Benchmark def free10000Scato = runScato(10000) @Benchmark def free10000Scalaz = runScalaz(10000) } object FreeMonadsScato { import clazz.{Functor, FunctorClass, Monad} import free.monad._ import transformers.State case class Op[A](a: A) object Op extends FunctorClass[Op] { def map[A, B](op: Op[A])(f: A => B): Op[B] = op match { case Op(a) => Op(f(a)) } } def mkFreeT[M[_]: Monad](size: Int): FreeT[Op, M, Unit] = { @tailrec def build(i: Int, prg: FreeT[Op, M, Unit]): FreeT[Op, M, Unit] = if (i < 1) prg else build(i - 1, prg.flatMap(_ => FreeT.liftF(Op(())))) build(size, FreeT.pure[Op, M, Unit](())) } def run(prg: FreeT[Op, State[Int, ?], Unit]): Int = State.exec(FreeT.run[Op, State[Int, ?], Unit](prg) { case Op(a) => State.modify[Int](_ + 1) })(0) } object FreeMonadsScalaz { import scalaz.{~>, Free, Functor, IndexedStateT, State, StateT, Monad} import Free.Trampoline case class Op[A](a: A) object Op { implicit val functor: Functor[Op] = new Functor[Op] { def map[A, B](op: Op[A])(f: A => B): Op[B] = Op(f(op.a)) } } val opToStateT: Op ~> StateT[Trampoline, Int, ?] = new (Op ~> StateT[Trampoline, Int, ?]) { override def apply[A](oa: Op[A]): StateT[Trampoline, Int, A] = oa match { case Op(a) => State.modify[Int](_ + 1).lift[Trampoline].flatMap(_ => State.state(a).lift[Trampoline]) } } def mkFree(size: Int): Free[Op, Unit] = { @tailrec def build(i: Int, prg: Free[Op, Unit]): Free[Op, Unit] = if (i < 1) prg else build(i - 1, prg.flatMap(_ => Free.liftF(Op(())))) build(size, Free.point[Op, Unit](())) } def run(prg: Free[Op, Unit]): Int = prg.foldMap[StateT[Trampoline, Int, ?]](opToStateT)(StateT.stateTMonadState[Int, Trampoline]).exec(0).run }
Example 14
Source File: Interpreters.scala From scato with Apache License 2.0 | 5 votes |
package scato package benchmarks import org.openjdk.jmh.annotations.{Benchmark, BenchmarkMode, Fork, Mode} object Scato { import Prelude._ import transformers.State def mkState[F[_]](xs: F[Int])(f: Long => (Unit, Long))(implicit F: Traversable[F]): State[Long, Unit] = xs.foldLeft(State.pure[Long, Unit](()))((s, _) => s.flatMap(_ => State.state(f))) def run[F[_]](xs: F[Int])(f: Long => (Unit, Long))(implicit F: Traversable[F]): (Unit, Long) = State.run(mkState(xs)(f))(0) } object Scalaz { import scalaz._ import scalaz.State import scalaz.Free._ import scalaz.syntax.traverse._ def mkState[F[_]](xs: F[Int])(f: Long => (Long, Unit))(implicit F: Traverse[F]) = xs.foldLeft(State.state[Long, Unit](()).liftF)((s, _) => s.flatMap(_ => State[Long, Unit](s => f(s)).liftF)) def run[F[_]](xs: F[Int])(f: Long => (Long, Unit))(implicit F: Traverse[F]): (Long, Unit) = mkState(xs)(f).foldRun(0L)((a,b) => b(a)) } @Fork(1) @BenchmarkMode(Array(Mode.Throughput)) class Interpreters { import Data._ def f0(i: Long): (Unit, Long) = ((), i + 1) def f1(i: Long): (Long, Unit) = (i + 1, ()) @Benchmark def scalaz = { import _root_.scalaz.std.AllInstances._ Scalaz.run(xs)(f1 _) } @Benchmark def scato = Scato.run(xs)(f0 _) }
Example 15
Source File: RESPBench.scala From laserdisc with MIT License | 5 votes |
package laserdisc package protocol import java.nio.charset.StandardCharsets.UTF_8 import org.openjdk.jmh.annotations.{Benchmark, Scope, State} import scodec.bits.BitVector import scodec.codecs.utf8 import scodec.{Attempt, Codec} @State(Scope.Benchmark) class RESPBench { private final val codec = Codec[RESP] private final val chars = 2000 private final val ok = "OK" private final val okRedis = s"+$ok$CRLF" private final val rtProblem = "runtime problem" private final val rtProblemRedis = s"-$rtProblem$CRLF" private final val fortyTwo = 42L private final val fortyTwoRedis = s":$fortyTwo$CRLF" private final val longString = new String(Array.fill(chars)('a')) private final val longStringRedis = s"$$$chars$CRLF$longString$CRLF" private final val longStringI = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" private final val str = Str(ok) private final val strBits = BitVector(okRedis.getBytes(UTF_8)) private final val err = Err(rtProblem) private final val errBits = BitVector(rtProblemRedis.getBytes(UTF_8)) private final val num = Num(fortyTwo) private final val numBits = BitVector(fortyTwoRedis.getBytes(UTF_8)) private final val bulk = Bulk(longString) private final val bulkBits = BitVector(longStringRedis.getBytes(UTF_8)) private final val longStringBits = BitVector(longString.getBytes(UTF_8)) private final val longStringIBits = BitVector(longStringI.getBytes(UTF_8)) @Benchmark def baseline_utf8_encode: Attempt[BitVector] = utf8.encode(longString) @Benchmark def baseline_utf8_decode: Attempt[String] = utf8.decodeValue(longStringBits) @Benchmark def baseline_utf8_encodeI: Attempt[BitVector] = utf8.encode(longStringI) @Benchmark def baseline_utf8_decodeI: Attempt[String] = utf8.decodeValue(longStringIBits) @Benchmark def str_encode: Attempt[BitVector] = codec.encode(str) @Benchmark def str_decode: Attempt[RESP] = codec.decodeValue(strBits) @Benchmark def err_encode: Attempt[BitVector] = codec.encode(err) @Benchmark def err_decode: Attempt[RESP] = codec.decodeValue(errBits) @Benchmark def num_encode: Attempt[BitVector] = codec.encode(num) @Benchmark def num_decode: Attempt[RESP] = codec.decodeValue(numBits) @Benchmark def bulk_encode: Attempt[BitVector] = codec.encode(bulk) @Benchmark def bulk_decode: Attempt[RESP] = codec.decodeValue(bulkBits) }
Example 16
Source File: ProtocolBenchArr.scala From laserdisc with MIT License | 5 votes |
package laserdisc package protocol import org.openjdk.jmh.annotations.{Benchmark, Scope, State} import org.openjdk.jmh.infra.Blackhole import shapeless._ @State(Scope.Benchmark) class ProtocolBenchArr { final case class A(s: List[String]) implicit val ev1: Arr ==> A = Read.infallible { arr => A(arr.elements.map { case Bulk(s) => s case _ => "" }) } private final def protocol = Protocol("CUSTOM", _: String :: HNil).as[Arr, Seq[Long]] private final def protocolArr = Protocol("CUSTOM", _: String :: HNil).as[Arr, Seq[A]] private final def protocolWithNull = Protocol("CUSTOM", _: String :: HNil).as[Arr, Seq[Option[Long]]] private final def protocolArrWithNull = Protocol("CUSTOM", _: String :: HNil).as[Arr, Seq[Option[A]]] private final def protocolPairs = Protocol("CUSTOM", _: String :: HNil).as[Arr, Seq[(String, Long)]] private final val request = "id" :: HNil private final val response1 = Arr(Bulk("1"), Bulk("2"), Bulk("3"), Bulk("4"), Bulk("5"), Bulk("6"), Bulk("7"), Bulk("8"), Bulk("9"), Bulk("10"), Bulk("11"), Bulk("12"), Bulk("13"), Bulk("14"), Bulk("15"), Bulk("16"), Bulk("17"), Bulk("18"), Bulk("19"), Bulk("20"), Bulk("1"), Bulk("2"), Bulk("3"), Bulk("4"), Bulk("5"), Bulk("6"), Bulk("7"), Bulk("8"), Bulk("9"), Bulk("10"), Bulk("11"), Bulk("12"), Bulk("13"), Bulk("14"), Bulk("15"), Bulk("16"), Bulk("17"), Bulk("18"), Bulk("19"), Bulk("20")) private final val response2 = Arr(Bulk("1"), NullBulk, Bulk("3"), NullBulk, Bulk("5"), Bulk("6"), NullBulk, NullBulk, Bulk("9"), NullBulk, Bulk("11"), Bulk("12"), NullBulk, Bulk("14"), NullBulk, Bulk("16"), Bulk("17"), Bulk("18"), NullBulk, Bulk("20"), Bulk("1"), NullBulk, Bulk("3"), NullBulk, Bulk("5"), Bulk("6"), NullBulk, NullBulk, Bulk("9"), NullBulk, Bulk("11"), Bulk("12"), NullBulk, Bulk("14"), NullBulk, Bulk("16"), Bulk("17"), Bulk("18"), NullBulk, Bulk("20")) private final val response3 = Arr( Arr(Bulk("1"), Bulk("2"), Bulk("3"), Bulk("4"), Bulk("5"), Bulk("6"), Bulk("7"), Bulk("8"), Bulk("9"), Bulk("10"), Bulk("11"), Bulk("12"), Bulk("13"), Bulk("14"), Bulk("15"), Bulk("16"), Bulk("17"), Bulk("18"), Bulk("19"), Bulk("20"), Bulk("1"), Bulk("2"), Bulk("3"), Bulk("4"), Bulk("5"), Bulk("6"), Bulk("7"), Bulk("8"), Bulk("9"), Bulk("10"), Bulk("11"), Bulk("12"), Bulk("13"), Bulk("14"), Bulk("15"), Bulk("16"), Bulk("17"), Bulk("18"), Bulk("19"), Bulk("20")), Arr(Bulk("1"), Bulk("2"), Bulk("3"), Bulk("4"), Bulk("5"), Bulk("6"), Bulk("7"), Bulk("8"), Bulk("9"), Bulk("10"), Bulk("11"), Bulk("12"), Bulk("13"), Bulk("14"), Bulk("15"), Bulk("16"), Bulk("17"), Bulk("18"), Bulk("19"), Bulk("20"), Bulk("1"), Bulk("2"), Bulk("3"), Bulk("4"), Bulk("5"), Bulk("6"), Bulk("7"), Bulk("8"), Bulk("9"), Bulk("10"), Bulk("11"), Bulk("12"), Bulk("13"), Bulk("14"), Bulk("15"), Bulk("16"), Bulk("17"), Bulk("18"), Bulk("19"), Bulk("20")), Arr(Bulk("1"), Bulk("2"), Bulk("3"), Bulk("4"), Bulk("5"), Bulk("6"), Bulk("7"), Bulk("8"), Bulk("9"), Bulk("10"), Bulk("11"), Bulk("12"), Bulk("13"), Bulk("14"), Bulk("15"), Bulk("16"), Bulk("17"), Bulk("18"), Bulk("19"), Bulk("20"), Bulk("1"), Bulk("2"), Bulk("3"), Bulk("4"), Bulk("5"), Bulk("6"), Bulk("7"), Bulk("8"), Bulk("9"), Bulk("10"), Bulk("11"), Bulk("12"), Bulk("13"), Bulk("14"), Bulk("15"), Bulk("16"), Bulk("17"), Bulk("18"), Bulk("19"), Bulk("20")), Arr(Bulk("1"), Bulk("2"), Bulk("3"), Bulk("4"), Bulk("5"), Bulk("6"), Bulk("7"), Bulk("8"), Bulk("9"), Bulk("10"), Bulk("11"), Bulk("12"), Bulk("13"), Bulk("14"), Bulk("15"), Bulk("16"), Bulk("17"), Bulk("18"), Bulk("19"), Bulk("20"), Bulk("1"), Bulk("2"), Bulk("3"), Bulk("4"), Bulk("5"), Bulk("6"), Bulk("7"), Bulk("8"), Bulk("9"), Bulk("10"), Bulk("11"), Bulk("12"), Bulk("13"), Bulk("14"), Bulk("15"), Bulk("16"), Bulk("17"), Bulk("18"), Bulk("19"), Bulk("20")), Arr(Bulk("1"), Bulk("2"), Bulk("3"), Bulk("4"), Bulk("5"), Bulk("6"), Bulk("7"), Bulk("8"), Bulk("9"), Bulk("10"), Bulk("11"), Bulk("12"), Bulk("13"), Bulk("14"), Bulk("15"), Bulk("16"), Bulk("17"), Bulk("18"), Bulk("19"), Bulk("20"), Bulk("1"), Bulk("2"), Bulk("3"), Bulk("4"), Bulk("5"), Bulk("6"), Bulk("7"), Bulk("8"), Bulk("9"), Bulk("10"), Bulk("11"), Bulk("12"), Bulk("13"), Bulk("14"), Bulk("15"), Bulk("16"), Bulk("17"), Bulk("18"), Bulk("19"), Bulk("20")), Arr(Bulk("1"), Bulk("2"), Bulk("3"), Bulk("4"), Bulk("5"), Bulk("6"), Bulk("7"), Bulk("8"), Bulk("9"), Bulk("10"), Bulk("11"), Bulk("12"), Bulk("13"), Bulk("14"), Bulk("15"), Bulk("16"), Bulk("17"), Bulk("18"), Bulk("19"), Bulk("20"), Bulk("1"), Bulk("2"), Bulk("3"), Bulk("4"), Bulk("5"), Bulk("6"), Bulk("7"), Bulk("8"), Bulk("9"), Bulk("10"), Bulk("11"), Bulk("12"), Bulk("13"), Bulk("14"), Bulk("15"), Bulk("16"), Bulk("17"), Bulk("18"), Bulk("19"), Bulk("20")), Arr(Bulk("1"), Bulk("2"), Bulk("3"), Bulk("4"), Bulk("5"), Bulk("6"), Bulk("7"), Bulk("8"), Bulk("9"), Bulk("10"), Bulk("11"), Bulk("12"), Bulk("13"), Bulk("14"), Bulk("15"), Bulk("16"), Bulk("17"), Bulk("18"), Bulk("19"), Bulk("20"), Bulk("1"), Bulk("2"), Bulk("3"), Bulk("4"), Bulk("5"), Bulk("6"), Bulk("7"), Bulk("8"), Bulk("9"), Bulk("10"), Bulk("11"), Bulk("12"), Bulk("13"), Bulk("14"), Bulk("15"), Bulk("16"), Bulk("17"), Bulk("18"), Bulk("19"), Bulk("20")), Arr(Bulk("1"), Bulk("2"), Bulk("3"), Bulk("4"), Bulk("5"), Bulk("6"), Bulk("7"), Bulk("8"), Bulk("9"), Bulk("10"), Bulk("11"), Bulk("12"), Bulk("13"), Bulk("14"), Bulk("15"), Bulk("16"), Bulk("17"), Bulk("18"), Bulk("19"), Bulk("20"), Bulk("1"), Bulk("2"), Bulk("3"), Bulk("4"), Bulk("5"), Bulk("6"), Bulk("7"), Bulk("8"), Bulk("9"), Bulk("10"), Bulk("11"), Bulk("12"), Bulk("13"), Bulk("14"), Bulk("15"), Bulk("16"), Bulk("17"), Bulk("18"), Bulk("19"), Bulk("20")), Arr(Bulk("1"), Bulk("2"), Bulk("3"), Bulk("4"), Bulk("5"), Bulk("6"), Bulk("7"), Bulk("8"), Bulk("9"), Bulk("10"), Bulk("11"), Bulk("12"), Bulk("13"), Bulk("14"), Bulk("15"), Bulk("16"), Bulk("17"), Bulk("18"), Bulk("19"), Bulk("20"), Bulk("1"), Bulk("2"), Bulk("3"), Bulk("4"), Bulk("5"), Bulk("6"), Bulk("7"), Bulk("8"), Bulk("9"), Bulk("10"), Bulk("11"), Bulk("12"), Bulk("13"), Bulk("14"), Bulk("15"), Bulk("16"), Bulk("17"), Bulk("18"), Bulk("19"), Bulk("20")), Arr(Bulk("1"), Bulk("2"), Bulk("3"), Bulk("4"), Bulk("5"), Bulk("6"), Bulk("7"), Bulk("8"), Bulk("9"), Bulk("10"), Bulk("11"), Bulk("12"), Bulk("13"), Bulk("14"), Bulk("15"), Bulk("16"), Bulk("17"), Bulk("18"), Bulk("19"), Bulk("20"), Bulk("1"), Bulk("2"), Bulk("3"), Bulk("4"), Bulk("5"), Bulk("6"), Bulk("7"), Bulk("8"), Bulk("9"), Bulk("10"), Bulk("11"), Bulk("12"), Bulk("13"), Bulk("14"), Bulk("15"), Bulk("16"), Bulk("17"), Bulk("18"), Bulk("19"), Bulk("20")), Arr(Bulk("1"), Bulk("2"), Bulk("3"), Bulk("4"), Bulk("5"), Bulk("6"), Bulk("7"), Bulk("8"), Bulk("9"), Bulk("10"), Bulk("11"), Bulk("12"), Bulk("13"), Bulk("14"), Bulk("15"), Bulk("16"), Bulk("17"), Bulk("18"), Bulk("19"), Bulk("20"), Bulk("1"), Bulk("2"), Bulk("3"), Bulk("4"), Bulk("5"), Bulk("6"), Bulk("7"), Bulk("8"), Bulk("9"), Bulk("10"), Bulk("11"), Bulk("12"), Bulk("13"), Bulk("14"), Bulk("15"), Bulk("16"), Bulk("17"), Bulk("18"), Bulk("19"), Bulk("20")), Arr(Bulk("1"), Bulk("2"), Bulk("3"), Bulk("4"), Bulk("5"), Bulk("6"), Bulk("7"), Bulk("8"), Bulk("9"), Bulk("10"), Bulk("11"), Bulk("12"), Bulk("13"), Bulk("14"), Bulk("15"), Bulk("16"), Bulk("17"), Bulk("18"), Bulk("19"), Bulk("20"), Bulk("1"), Bulk("2"), Bulk("3"), Bulk("4"), Bulk("5"), Bulk("6"), Bulk("7"), Bulk("8"), Bulk("9"), Bulk("10"), Bulk("11"), Bulk("12"), Bulk("13"), Bulk("14"), Bulk("15"), Bulk("16"), Bulk("17"), Bulk("18"), Bulk("19"), Bulk("20")), Arr(Bulk("1"), Bulk("2"), Bulk("3"), Bulk("4"), Bulk("5"), Bulk("6"), Bulk("7"), Bulk("8"), Bulk("9"), Bulk("10"), Bulk("11"), Bulk("12"), Bulk("13"), Bulk("14"), Bulk("15"), Bulk("16"), Bulk("17"), Bulk("18"), Bulk("19"), Bulk("20"), Bulk("1"), Bulk("2"), Bulk("3"), Bulk("4"), Bulk("5"), Bulk("6"), Bulk("7"), Bulk("8"), Bulk("9"), Bulk("10"), Bulk("11"), Bulk("12"), Bulk("13"), Bulk("14"), Bulk("15"), Bulk("16"), Bulk("17"), Bulk("18"), Bulk("19"), Bulk("20")), Arr(Bulk("1"), Bulk("2"), Bulk("3"), Bulk("4"), Bulk("5"), Bulk("6"), Bulk("7"), Bulk("8"), Bulk("9"), Bulk("10"), Bulk("11"), Bulk("12"), Bulk("13"), Bulk("14"), Bulk("15"), Bulk("16"), Bulk("17"), Bulk("18"), Bulk("19"), Bulk("20"), Bulk("1"), Bulk("2"), Bulk("3"), Bulk("4"), Bulk("5"), Bulk("6"), Bulk("7"), Bulk("8"), Bulk("9"), Bulk("10"), Bulk("11"), Bulk("12"), Bulk("13"), Bulk("14"), Bulk("15"), Bulk("16"), Bulk("17"), Bulk("18"), Bulk("19"), Bulk("20")), Arr(Bulk("1"), Bulk("2"), Bulk("3"), Bulk("4"), Bulk("5"), Bulk("6"), Bulk("7"), Bulk("8"), Bulk("9"), Bulk("10"), Bulk("11"), Bulk("12"), Bulk("13"), Bulk("14"), Bulk("15"), Bulk("16"), Bulk("17"), Bulk("18"), Bulk("19"), Bulk("20"), Bulk("1"), Bulk("2"), Bulk("3"), Bulk("4"), Bulk("5"), Bulk("6"), Bulk("7"), Bulk("8"), Bulk("9"), Bulk("10"), Bulk("11"), Bulk("12"), Bulk("13"), Bulk("14"), Bulk("15"), Bulk("16"), Bulk("17"), Bulk("18"), Bulk("19"), Bulk("20")), Arr(Bulk("1"), Bulk("2"), Bulk("3"), Bulk("4"), Bulk("5"), Bulk("6"), Bulk("7"), Bulk("8"), Bulk("9"), Bulk("10"), Bulk("11"), Bulk("12"), Bulk("13"), Bulk("14"), Bulk("15"), Bulk("16"), Bulk("17"), Bulk("18"), Bulk("19"), Bulk("20"), Bulk("1"), Bulk("2"), Bulk("3"), Bulk("4"), Bulk("5"), Bulk("6"), Bulk("7"), Bulk("8"), Bulk("9"), Bulk("10"), Bulk("11"), Bulk("12"), Bulk("13"), Bulk("14"), Bulk("15"), Bulk("16"), Bulk("17"), Bulk("18"), Bulk("19"), Bulk("20")), Arr(Bulk("1"), Bulk("2"), Bulk("3"), Bulk("4"), Bulk("5"), Bulk("6"), Bulk("7"), Bulk("8"), Bulk("9"), Bulk("10"), Bulk("11"), Bulk("12"), Bulk("13"), Bulk("14"), Bulk("15"), Bulk("16"), Bulk("17"), Bulk("18"), Bulk("19"), Bulk("20"), Bulk("1"), Bulk("2"), Bulk("3"), Bulk("4"), Bulk("5"), Bulk("6"), Bulk("7"), Bulk("8"), Bulk("9"), Bulk("10"), Bulk("11"), Bulk("12"), Bulk("13"), Bulk("14"), Bulk("15"), Bulk("16"), Bulk("17"), Bulk("18"), Bulk("19"), Bulk("20")), Arr(Bulk("1"), Bulk("2"), Bulk("3"), Bulk("4"), Bulk("5"), Bulk("6"), Bulk("7"), Bulk("8"), Bulk("9"), Bulk("10"), Bulk("11"), Bulk("12"), Bulk("13"), Bulk("14"), Bulk("15"), Bulk("16"), Bulk("17"), Bulk("18"), Bulk("19"), Bulk("20"), Bulk("1"), Bulk("2"), Bulk("3"), Bulk("4"), Bulk("5"), Bulk("6"), Bulk("7"), Bulk("8"), Bulk("9"), Bulk("10"), Bulk("11"), Bulk("12"), Bulk("13"), Bulk("14"), Bulk("15"), Bulk("16"), Bulk("17"), Bulk("18"), Bulk("19"), Bulk("20")), Arr(Bulk("1"), Bulk("2"), Bulk("3"), Bulk("4"), Bulk("5"), Bulk("6"), Bulk("7"), Bulk("8"), Bulk("9"), Bulk("10"), Bulk("11"), Bulk("12"), Bulk("13"), Bulk("14"), Bulk("15"), Bulk("16"), Bulk("17"), Bulk("18"), Bulk("19"), Bulk("20"), Bulk("1"), Bulk("2"), Bulk("3"), Bulk("4"), Bulk("5"), Bulk("6"), Bulk("7"), Bulk("8"), Bulk("9"), Bulk("10"), Bulk("11"), Bulk("12"), Bulk("13"), Bulk("14"), Bulk("15"), Bulk("16"), Bulk("17"), Bulk("18"), Bulk("19"), Bulk("20")), Arr(Bulk("1"), Bulk("2"), Bulk("3"), Bulk("4"), Bulk("5"), Bulk("6"), Bulk("7"), Bulk("8"), Bulk("9"), Bulk("10"), Bulk("11"), Bulk("12"), Bulk("13"), Bulk("14"), Bulk("15"), Bulk("16"), Bulk("17"), Bulk("18"), Bulk("19"), Bulk("20"), Bulk("1"), Bulk("2"), Bulk("3"), Bulk("4"), Bulk("5"), Bulk("6"), Bulk("7"), Bulk("8"), Bulk("9"), Bulk("10"), Bulk("11"), Bulk("12"), Bulk("13"), Bulk("14"), Bulk("15"), Bulk("16"), Bulk("17"), Bulk("18"), Bulk("19"), Bulk("20")) ) private final val response4 = Arr( Arr(Bulk("1"), NullBulk, Bulk("3"), NullBulk, Bulk("5"), Bulk("6"), NullBulk, NullBulk, Bulk("9"), NullBulk, Bulk("11"), Bulk("12"), NullBulk, Bulk("14"), NullBulk, Bulk("16"), Bulk("17"), Bulk("18"), NullBulk, Bulk("20"), Bulk("1"), NullBulk, Bulk("3"), NullBulk, Bulk("5"), Bulk("6"), NullBulk, NullBulk, Bulk("9"), NullBulk, Bulk("11"), Bulk("12"), NullBulk, Bulk("14"), NullBulk, Bulk("16"), Bulk("17"), Bulk("18"), NullBulk, Bulk("20")), Arr(Bulk("2"), Bulk("1"), Bulk("3"), NullBulk, Bulk("5"), NullBulk, Bulk("7"), NullBulk, Bulk("9"), NullBulk, NullBulk, NullBulk, NullBulk, NullBulk, Bulk("15"), Bulk("16"), NullBulk, Bulk("18"), Bulk("19"), NullBulk, Bulk("1"), Bulk("2"), Bulk("3"), NullBulk, Bulk("5"), NullBulk, Bulk("7"), NullBulk, Bulk("9"), NullBulk, NullBulk, NullBulk, NullBulk, NullBulk, Bulk("15"), Bulk("16"), NullBulk, Bulk("18"), Bulk("19"), NullBulk), Arr(Bulk("1"), Bulk("2"), Bulk("3"), Bulk("4"), NullBulk, Bulk("6"), Bulk("7"), Bulk("8"), Bulk("9"), Bulk("10"), Bulk("11"), Bulk("12"), Bulk("13"), Bulk("14"), Bulk("15"), Bulk("16"), Bulk("17"), Bulk("18"), NullBulk, Bulk("20"), Bulk("1"), Bulk("2"), Bulk("3"), Bulk("4"), NullBulk, Bulk("6"), Bulk("7"), Bulk("8"), Bulk("9"), Bulk("10"), Bulk("11"), Bulk("12"), Bulk("13"), Bulk("14"), Bulk("15"), Bulk("16"), Bulk("17"), Bulk("18"), NullBulk, Bulk("20")), Arr(Bulk("1"), NullBulk, Bulk("3"), NullBulk, Bulk("5"), Bulk("6"), NullBulk, NullBulk, Bulk("9"), NullBulk, Bulk("11"), Bulk("12"), NullBulk, Bulk("14"), NullBulk, Bulk("16"), Bulk("17"), Bulk("18"), NullBulk, Bulk("20"), Bulk("1"), NullBulk, Bulk("3"), NullBulk, Bulk("5"), Bulk("6"), NullBulk, NullBulk, Bulk("9"), NullBulk, Bulk("11"), Bulk("12"), NullBulk, Bulk("14"), NullBulk, Bulk("16"), Bulk("17"), Bulk("18"), NullBulk, Bulk("20")), Arr(Bulk("1"), Bulk("2"), Bulk("3"), NullBulk, Bulk("5"), NullBulk, Bulk("7"), NullBulk, Bulk("9"), NullBulk, NullBulk, NullBulk, NullBulk, NullBulk, Bulk("15"), Bulk("16"), NullBulk, Bulk("18"), Bulk("19"), NullBulk, Bulk("1"), Bulk("2"), Bulk("3"), NullBulk, Bulk("5"), NullBulk, Bulk("7"), NullBulk, Bulk("9"), NullBulk, NullBulk, NullBulk, NullBulk, NullBulk, Bulk("15"), Bulk("16"), NullBulk, Bulk("18"), Bulk("19"), NullBulk), Arr(Bulk("1"), Bulk("2"), Bulk("3"), Bulk("4"), Bulk("5"), Bulk("6"), Bulk("7"), Bulk("8"), Bulk("9"), Bulk("10"), Bulk("11"), Bulk("12"), Bulk("13"), Bulk("14"), Bulk("15"), Bulk("16"), Bulk("17"), Bulk("18"), NullBulk, Bulk("20"), Bulk("1"), Bulk("2"), Bulk("3"), Bulk("4"), Bulk("5"), Bulk("6"), Bulk("7"), Bulk("8"), Bulk("9"), Bulk("10"), Bulk("11"), Bulk("12"), Bulk("13"), Bulk("14"), Bulk("15"), Bulk("16"), Bulk("17"), Bulk("18"), NullBulk, Bulk("20")), Arr(Bulk("1"), NullBulk, Bulk("3"), NullBulk, Bulk("5"), Bulk("6"), NullBulk, NullBulk, Bulk("9"), NullBulk, Bulk("11"), Bulk("12"), NullBulk, Bulk("14"), NullBulk, Bulk("16"), Bulk("17"), Bulk("18"), NullBulk, Bulk("20"), Bulk("1"), NullBulk, Bulk("3"), NullBulk, Bulk("5"), Bulk("6"), NullBulk, NullBulk, Bulk("9"), NullBulk, Bulk("11"), Bulk("12"), NullBulk, Bulk("14"), NullBulk, Bulk("16"), Bulk("17"), Bulk("18"), NullBulk, Bulk("20")), Arr(Bulk("1"), Bulk("2"), Bulk("3"), NullBulk, Bulk("5"), NullBulk, Bulk("7"), NullBulk, Bulk("9"), NullBulk, NullBulk, NullBulk, NullBulk, NullBulk, Bulk("15"), Bulk("16"), NullBulk, Bulk("18"), Bulk("19"), NullBulk, Bulk("1"), Bulk("2"), Bulk("3"), NullBulk, Bulk("5"), NullBulk, Bulk("7"), NullBulk, Bulk("9"), NullBulk, NullBulk, NullBulk, NullBulk, NullBulk, Bulk("15"), Bulk("16"), NullBulk, Bulk("18"), Bulk("19"), NullBulk), Arr(Bulk("1"), NullBulk, Bulk("3"), NullBulk, Bulk("5"), Bulk("6"), NullBulk, NullBulk, Bulk("9"), NullBulk, Bulk("11"), Bulk("12"), NullBulk, Bulk("14"), NullBulk, Bulk("16"), Bulk("17"), Bulk("18"), NullBulk, Bulk("20"), Bulk("1"), NullBulk, Bulk("3"), NullBulk, Bulk("5"), Bulk("6"), NullBulk, NullBulk, Bulk("9"), NullBulk, Bulk("11"), Bulk("12"), NullBulk, Bulk("14"), NullBulk, Bulk("16"), Bulk("17"), Bulk("18"), NullBulk, Bulk("20")), Arr(Bulk("1"), Bulk("2"), Bulk("3"), Bulk("4"), Bulk("5"), Bulk("6"), Bulk("7"), Bulk("8"), Bulk("9"), Bulk("10"), Bulk("11"), Bulk("12"), Bulk("13"), Bulk("14"), Bulk("15"), NullBulk, Bulk("17"), Bulk("18"), Bulk("19"), Bulk("20"), Bulk("1"), Bulk("2"), Bulk("3"), Bulk("4"), Bulk("5"), Bulk("6"), Bulk("7"), Bulk("8"), Bulk("9"), Bulk("10"), Bulk("11"), Bulk("12"), Bulk("13"), Bulk("14"), Bulk("15"), NullBulk, Bulk("17"), Bulk("18"), Bulk("19"), Bulk("20")), Arr(Bulk("1"), Bulk("2"), Bulk("3"), NullBulk, Bulk("5"), NullBulk, Bulk("7"), NullBulk, Bulk("9"), NullBulk, NullBulk, NullBulk, NullBulk, NullBulk, Bulk("15"), Bulk("16"), NullBulk, Bulk("18"), Bulk("19"), NullBulk, Bulk("1"), Bulk("2"), Bulk("3"), NullBulk, Bulk("5"), NullBulk, Bulk("7"), NullBulk, Bulk("9"), NullBulk, NullBulk, NullBulk, NullBulk, NullBulk, Bulk("15"), Bulk("16"), NullBulk, Bulk("18"), Bulk("19"), NullBulk), Arr(Bulk("1"), NullBulk, Bulk("3"), NullBulk, Bulk("5"), Bulk("6"), NullBulk, NullBulk, Bulk("9"), NullBulk, Bulk("11"), Bulk("12"), NullBulk, Bulk("14"), NullBulk, Bulk("16"), Bulk("17"), Bulk("18"), NullBulk, Bulk("20"), Bulk("1"), NullBulk, Bulk("3"), NullBulk, Bulk("5"), Bulk("6"), NullBulk, NullBulk, Bulk("9"), NullBulk, Bulk("11"), Bulk("12"), NullBulk, Bulk("14"), NullBulk, Bulk("16"), Bulk("17"), Bulk("18"), NullBulk, Bulk("20")), Arr(Bulk("1"), Bulk("2"), Bulk("3"), Bulk("4"), Bulk("5"), Bulk("6"), Bulk("7"), Bulk("8"), Bulk("9"), Bulk("10"), Bulk("11"), Bulk("12"), Bulk("13"), Bulk("14"), NullBulk, Bulk("16"), Bulk("17"), Bulk("18"), Bulk("19"), Bulk("20"), Bulk("1"), Bulk("2"), Bulk("3"), Bulk("4"), Bulk("5"), Bulk("6"), Bulk("7"), Bulk("8"), Bulk("9"), Bulk("10"), Bulk("11"), Bulk("12"), Bulk("13"), Bulk("14"), NullBulk, Bulk("16"), Bulk("17"), Bulk("18"), Bulk("19"), Bulk("20")), Arr(Bulk("1"), Bulk("2"), Bulk("3"), NullBulk, Bulk("5"), NullBulk, Bulk("7"), NullBulk, Bulk("9"), NullBulk, NullBulk, NullBulk, NullBulk, NullBulk, Bulk("15"), Bulk("16"), NullBulk, Bulk("18"), Bulk("19"), NullBulk, Bulk("1"), Bulk("2"), Bulk("3"), NullBulk, Bulk("5"), NullBulk, Bulk("7"), NullBulk, Bulk("9"), NullBulk, NullBulk, NullBulk, NullBulk, NullBulk, Bulk("15"), Bulk("16"), NullBulk, Bulk("18"), Bulk("19"), NullBulk), Arr(Bulk("1"), Bulk("2"), Bulk("3"), Bulk("4"), Bulk("5"), Bulk("6"), Bulk("7"), Bulk("8"), Bulk("9"), Bulk("10"), Bulk("11"), Bulk("12"), Bulk("13"), Bulk("14"), Bulk("15"), Bulk("16"), Bulk("17"), Bulk("18"), Bulk("19"), Bulk("20"), Bulk("1"), Bulk("2"), Bulk("3"), Bulk("4"), Bulk("5"), Bulk("6"), Bulk("7"), Bulk("8"), Bulk("9"), Bulk("10"), Bulk("11"), Bulk("12"), Bulk("13"), Bulk("14"), Bulk("15"), Bulk("16"), Bulk("17"), Bulk("18"), Bulk("19"), Bulk("20")), Arr(Bulk("1"), NullBulk, Bulk("3"), NullBulk, Bulk("5"), Bulk("6"), NullBulk, NullBulk, Bulk("9"), NullBulk, Bulk("11"), Bulk("12"), NullBulk, Bulk("14"), NullBulk, Bulk("16"), Bulk("17"), Bulk("18"), NullBulk, Bulk("20"), Bulk("1"), NullBulk, Bulk("3"), NullBulk, Bulk("5"), Bulk("6"), NullBulk, NullBulk, Bulk("9"), NullBulk, Bulk("11"), Bulk("12"), NullBulk, Bulk("14"), NullBulk, Bulk("16"), Bulk("17"), Bulk("18"), NullBulk, Bulk("20")), Arr(Bulk("1"), Bulk("2"), Bulk("3"), NullBulk, Bulk("5"), NullBulk, Bulk("7"), NullBulk, Bulk("9"), NullBulk, NullBulk, NullBulk, NullBulk, NullBulk, Bulk("15"), Bulk("16"), NullBulk, Bulk("18"), Bulk("19"), NullBulk, Bulk("1"), Bulk("2"), Bulk("3"), NullBulk, Bulk("5"), NullBulk, Bulk("7"), NullBulk, Bulk("9"), NullBulk, NullBulk, NullBulk, NullBulk, NullBulk, Bulk("15"), Bulk("16"), NullBulk, Bulk("18"), Bulk("19"), NullBulk), Arr(Bulk("1"), Bulk("2"), Bulk("3"), Bulk("4"), Bulk("5"), Bulk("6"), Bulk("7"), Bulk("8"), Bulk("9"), Bulk("10"), Bulk("11"), Bulk("12"), Bulk("13"), Bulk("14"), Bulk("15"), Bulk("16"), Bulk("17"), Bulk("18"), Bulk("19"), Bulk("20"), Bulk("1"), Bulk("2"), Bulk("3"), Bulk("4"), Bulk("5"), Bulk("6"), Bulk("7"), Bulk("8"), Bulk("9"), Bulk("10"), Bulk("11"), Bulk("12"), Bulk("13"), Bulk("14"), Bulk("15"), Bulk("16"), Bulk("17"), Bulk("18"), Bulk("19"), Bulk("20")), Arr(Bulk("1"), NullBulk, Bulk("3"), NullBulk, Bulk("5"), Bulk("6"), NullBulk, NullBulk, Bulk("9"), NullBulk, Bulk("11"), Bulk("12"), NullBulk, Bulk("14"), NullBulk, Bulk("16"), Bulk("17"), Bulk("18"), NullBulk, Bulk("20"), Bulk("1"), NullBulk, Bulk("3"), NullBulk, Bulk("5"), Bulk("6"), NullBulk, NullBulk, Bulk("9"), NullBulk, Bulk("11"), Bulk("12"), NullBulk, Bulk("14"), NullBulk, Bulk("16"), Bulk("17"), Bulk("18"), NullBulk, Bulk("20")), Arr(Bulk("1"), Bulk("2"), Bulk("3"), NullBulk, Bulk("5"), NullBulk, Bulk("7"), NullBulk, Bulk("9"), NullBulk, NullBulk, NullBulk, NullBulk, NullBulk, Bulk("15"), Bulk("16"), NullBulk, Bulk("18"), Bulk("19"), NullBulk, Bulk("1"), Bulk("2"), Bulk("3"), NullBulk, Bulk("5"), NullBulk, Bulk("7"), NullBulk, Bulk("9"), NullBulk, NullBulk, NullBulk, NullBulk, NullBulk, Bulk("15"), Bulk("16"), NullBulk, Bulk("18"), Bulk("19"), NullBulk) ) private final val response5 = Arr(Bulk("abcd-1"), Bulk("1"), Bulk("abcd-2"), Bulk("2"), Bulk("abcd-3"), Bulk("3"), Bulk("abcd-4"), Bulk("4"), Bulk("abcd-5"), Bulk("5"), Bulk("abcd-6"), Bulk("6"), Bulk("abcd-7"), Bulk("7"), Bulk("abcd-8"), Bulk("8"), Bulk("abcd-9"), Bulk("9"), Bulk("abcd-10"), Bulk("10"), Bulk("abcd-11"), Bulk("11"), Bulk("abcd-12"), Bulk("12"), Bulk("abcd-13"), Bulk("13"), Bulk("abcd-14"), Bulk("14"), Bulk("abcd-15"), Bulk("15"), Bulk("abcd-16"), Bulk("16"), Bulk("abcd-17"), Bulk("17"), Bulk("abcd-18"), Bulk("18"), Bulk("abcd-19"), Bulk("19"), Bulk("abcd-20"), Bulk("20"), Bulk("abcd-1"), Bulk("1"), Bulk("abcd-2"), Bulk("2"), Bulk("abcd-3"), Bulk("3"), Bulk("abcd-4"), Bulk("4"), Bulk("abcd-5"), Bulk("5"), Bulk("abcd-6"), Bulk("6"), Bulk("abcd-7"), Bulk("7"), Bulk("abcd-8"), Bulk("8"), Bulk("abcd-9"), Bulk("9"), Bulk("abcd-10"), Bulk("10"), Bulk("abcd-11"), Bulk("11"), Bulk("abcd-12"), Bulk("12"), Bulk("abcd-13"), Bulk("13"), Bulk("abcd-14"), Bulk("14"), Bulk("abcd-15"), Bulk("15"), Bulk("abcd-16"), Bulk("16"), Bulk("abcd-17"), Bulk("17"), Bulk("abcd-18"), Bulk("18"), Bulk("abcd-19"), Bulk("19"), Bulk("abcd-20"), Bulk("20")) @Benchmark def decodeArrBaseline(bh: Blackhole) = { val decoded = protocol(request).decode(Arr(Nil)) bh.consume(decoded) } @Benchmark def decodeArrOfBulk(bh: Blackhole) = { val decoded = protocol(request).decode(response1) bh.consume(decoded) } @Benchmark def decodeArrOfBulkWithNull(bh: Blackhole) = { val decoded = protocolWithNull(request).decode(response2) bh.consume(decoded) } @Benchmark def decodeArrOfArrOfBulk(bh: Blackhole) = { val decoded = protocol(request).decode(response3) bh.consume(decoded) } @Benchmark def decodeArrOfArrOfBulkWithNull(bh: Blackhole) = { val decoded = protocolWithNull(request).decode(response4) bh.consume(decoded) } @Benchmark def decodeArrOfPairs(bh: Blackhole) = { val decoded = protocolPairs(request).decode(response5) bh.consume(decoded) } }
Example 17
Source File: RESPFrameBench.scala From laserdisc with MIT License | 5 votes |
package laserdisc package protocol import org.openjdk.jmh.annotations.{Benchmark, Scope, State} import scodec.bits.BitVector import eu.timepit.refined.types.string.NonEmptyString import java.nio.ByteBuffer import laserdisc.RESPFrameFixture import org.openjdk.jmh.infra.Blackhole @State(Scope.Benchmark) class RESPFrameBench extends RESPFrameFixture { val mixedNoArr = bytesOf(mixedNoArrList) val arrOneLevel = bytesOf(arrOneLevelList) val arrFiveLevels = bytesOf(arrFiveLevelsList) val empty = BitVector.empty.toByteBuffer val mixedNoArrFull = BitVector(mixedNoArr).toByteBuffer val arrOneLevelFull = BitVector(arrOneLevel).toByteBuffer val arrFiveLevelsFull = BitVector(arrFiveLevels).toByteBuffer @Benchmark def frameOfFullBaseline(bh: Blackhole)= { val frame = EmptyFrame.append(empty) bh.consume(frame) } @Benchmark def frameOfMixedNoArrFull(bh: Blackhole) = { val frame = EmptyFrame.append(mixedNoArrFull) bh.consume(frame) } @Benchmark def frameOfMixedArrOneLevelFull(bh: Blackhole) = { val frame = EmptyFrame.append(arrOneLevelFull) bh.consume(frame) } @Benchmark def frameOfMixedArrFiveLevelsFull(bh: Blackhole) = { val frame = EmptyFrame.append(arrFiveLevelsFull) bh.consume(frame) } val mixedNoArrSmallChunkBuffers = groupInChunks(mixedNoArr, 128) val arrOneLevelSmallChunkBuffers = groupInChunks(arrOneLevel, 128) val arrFiveLevelsSmallChunkBuffers = groupInChunks(arrFiveLevels, 128) @Benchmark def frameOfChunkedBaseline(bh: Blackhole)= { val frames = appendChunks(Iterator.empty[BitVector]) bh.consume(frames) } @Benchmark def frameOfChunkedShortMixedNoArr(bh: Blackhole)= { val frames = appendChunks(mixedNoArrSmallChunkBuffers) bh.consume(frames) } @Benchmark def frameOfChunkedShortArrOneLevel(bh: Blackhole) = { val frames = appendChunks(arrOneLevelSmallChunkBuffers) bh.consume(frames) } @Benchmark def frameOfChunkedShortArrFiveLevels(bh: Blackhole) = { val frames = appendChunks(arrFiveLevelsSmallChunkBuffers) bh.consume(frames) } val mixedNoArrBigChunkBuffers = groupInChunks(mixedNoArr, 1024) val arrOneLevelBigChunkBuffers = groupInChunks(arrOneLevel, 1024) val arrFiveLevelsBigChunkBuffers = groupInChunks(arrFiveLevels, 1024) @Benchmark def frameOfChunkedLongMixedNoArr(bh: Blackhole) = { val frames = appendChunks(mixedNoArrBigChunkBuffers) bh.consume(frames) } @Benchmark def frameOfChunkedLongArrOneLevel(bh: Blackhole) = { val frames = appendChunks(arrOneLevelBigChunkBuffers) bh.consume(frames) } @Benchmark def frameOfChunkedLongArrFiveLevels(bh: Blackhole) = { val frames = appendChunks(arrFiveLevelsBigChunkBuffers) bh.consume(frames) } }
Example 18
Source File: GeoJSONWriting.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.PlayJsonFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.WeePickleFromTos._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.ToJson import com.rallyhealth.weepickle.v1.WeePickle.FromScala import io.circe.syntax._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ class GeoJSONWriting extends GeoJSONBenchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringOutput.write(obj).getBytes(UTF_8) @Benchmark def borer(): Array[Byte] = io.bullet.borer.Json.encode(obj).toByteArray @Benchmark def circe(): Array[Byte] = printer.print(obj.asJson).getBytes(UTF_8) @Benchmark def jacksonScala(): Array[Byte] = jacksonMapper.writeValueAsBytes(obj) @Benchmark def jsoniterScala(): Array[Byte] = writeToArray(obj) @Benchmark def jsoniterScalaPrealloc(): Int = writeToSubArray(obj, preallocatedBuf, 0, preallocatedBuf.length) @Benchmark def playJson(): Array[Byte] = Json.toBytes(Json.toJson(obj)(geoJSONFormat)) @Benchmark def sprayJson(): Array[Byte] = obj.toJson(geoJSONJsonFormat).compactPrint.getBytes(UTF_8) @Benchmark def uPickle(): Array[Byte] = write(obj).getBytes(UTF_8) @Benchmark def weePickle(): Array[Byte] = FromScala(obj).transform(ToJson.bytes) }
Example 19
Source File: StreamInputOutputBenchmark.scala From scala-commons with MIT License | 5 votes |
package com.avsystem.commons package ser import java.io.{ByteArrayInputStream, ByteArrayOutputStream, DataInputStream, DataOutputStream} import com.avsystem.commons.serialization.{GenCodec, StreamInput, StreamOutput} import org.openjdk.jmh.annotations.{Benchmark, BenchmarkMode, Fork, Measurement, Mode, Scope, State, Warmup} import org.openjdk.jmh.infra.Blackhole case class Toplevel(int: Int, nested: Nested, str: String) case class Nested(list: List[Int], int: Int) object Toplevel { implicit val nestedCodec: GenCodec[Nested] = GenCodec.materialize[Nested] implicit val codec: GenCodec[Toplevel] = GenCodec.materialize[Toplevel] } @Warmup(iterations = 10) @Measurement(iterations = 20) @Fork(1) @BenchmarkMode(Array(Mode.Throughput)) @State(Scope.Thread) class StreamInputOutputBenchmark { val something = Toplevel(35, Nested(List(121, 122, 123, 124, 125, 126), 53), "lol") val inputArray: Array[Byte] = { val os = new ByteArrayOutputStream() GenCodec.write(new StreamOutput(new DataOutputStream(os)), something) os.toByteArray } @Benchmark def testEncode(bh: Blackhole): Unit = { val os = new ByteArrayOutputStream(inputArray.length) val output = new StreamOutput(new DataOutputStream(os)) GenCodec.write(output, something) bh.consume(os.toByteArray) } @Benchmark def testDecode(bh: Blackhole): Unit = { val is = new DataInputStream(new ByteArrayInputStream(inputArray)) val input = new StreamInput(is) bh.consume(GenCodec.read[Toplevel](input)) } @Benchmark def testEncodeRaw(bh: Blackhole): Unit = { val os = new ByteArrayOutputStream(inputArray.length) val output = new StreamOutput(new DataOutputStream(os)) val toplevelOutput = output.writeObject() toplevelOutput.writeField("int").writeSimple().writeInt(35) val nestedOutput = toplevelOutput.writeField("nested").writeObject() val listOutput = nestedOutput.writeField("list").writeList() listOutput.writeElement().writeSimple().writeInt(121) listOutput.writeElement().writeSimple().writeInt(122) listOutput.writeElement().writeSimple().writeInt(123) listOutput.writeElement().writeSimple().writeInt(124) listOutput.writeElement().writeSimple().writeInt(125) listOutput.writeElement().writeSimple().writeInt(126) listOutput.finish() nestedOutput.writeField("int").writeSimple().writeInt(53) nestedOutput.finish() toplevelOutput.writeField("str").writeSimple().writeString("lol") toplevelOutput.finish() bh.consume(os.toByteArray) } @Benchmark def testDecodeRaw(bh: Blackhole): Unit = { val is = new DataInputStream(new ByteArrayInputStream(inputArray)) val input = new StreamInput(is) val objInput = input.readObject() val intField = objInput.nextField().readSimple().readInt() val nestedInput = objInput.nextField().readObject() val listInput = nestedInput.nextField().readList() val listNested = List( listInput.nextElement().readSimple().readInt(), listInput.nextElement().readSimple().readInt(), listInput.nextElement().readSimple().readInt(), listInput.nextElement().readSimple().readInt(), listInput.nextElement().readSimple().readInt(), listInput.nextElement().readSimple().readInt() ) listInput.hasNext val intNested = nestedInput.nextField().readSimple().readInt() nestedInput.hasNext val strField = objInput.nextField().readSimple().readString() objInput.hasNext bh.consume(Toplevel(intField, Nested(listNested, intNested), strField)) } }
Example 20
Source File: JavaSerializationBenchmark.scala From scala-commons with MIT License | 5 votes |
package com.avsystem.commons package rpc.akka.serialization import java.io.{ByteArrayInputStream, ByteArrayOutputStream, ObjectInputStream, ObjectOutputStream} import org.openjdk.jmh.annotations.{Benchmark, BenchmarkMode, Fork, Measurement, Mode, Scope, State, Warmup} import org.openjdk.jmh.infra.Blackhole @Warmup(iterations = 5) @Measurement(iterations = 20) @Fork(1) @BenchmarkMode(Array(Mode.Throughput)) @State(Scope.Thread) class JavaSerializationBenchmark { val something = Something(42, Nested(4 :: 8 :: 15 :: 16 :: 23 :: 42 :: Nil, 0), "lol") val array = { val baos = new ByteArrayOutputStream() val o = new ObjectOutputStream(baos) o.writeObject(something) o.close() baos.toByteArray } @Benchmark def byteStringOutput(): Something = { val baos = new ByteArrayOutputStream() val o = new ObjectOutputStream(baos) o.writeObject(something) o.close() val array = baos.toByteArray new ObjectInputStream(new ByteArrayInputStream(array)).readObject().asInstanceOf[Something] } @Benchmark def writeTest(): Array[Byte] = { val baos = new ByteArrayOutputStream() val o = new ObjectOutputStream(baos) o.writeObject(something) o.close() baos.toByteArray } @Benchmark def readTest(): Something = { new ObjectInputStream(new ByteArrayInputStream(array)).readObject().asInstanceOf[Something] } }
Example 21
Source File: BsonInputOutputBenchmark.scala From scala-commons with MIT License | 5 votes |
package com.avsystem.commons package mongo import java.io.StringWriter import java.nio.ByteBuffer import com.avsystem.commons.rpc.akka.serialization.{Nested, Something} import org.bson.io.BasicOutputBuffer import org.bson.json.{JsonReader, JsonWriter} import org.bson.{BsonBinaryReader, BsonBinaryWriter, BsonDocument, BsonDocumentReader, BsonDocumentWriter, BsonReader, BsonValue, BsonWriter} import org.openjdk.jmh.annotations.{Benchmark, BenchmarkMode, Fork, Measurement, Mode, Scope, State, Warmup} @Warmup(iterations = 10) @Measurement(iterations = 20) @Fork(1) @BenchmarkMode(Array(Mode.Throughput)) @State(Scope.Thread) class BsonInputOutputBenchmark { private val something = Something(42, Nested(List(4, 8, 15, 16, 23, 42, 0), 131), "lol") private val bytes = binaryEncode(something) private val doc = documentEncode(something) private val json = jsonEncode(something) def write(something: Something, bsonWriter: BsonWriter): Unit = { val output = new BsonWriterOutput(bsonWriter) Something.codec.write(output, something) } def binaryEncode(something: Something): Array[Byte] = { val bsonOutput = new BasicOutputBuffer() write(something, new BsonBinaryWriter(bsonOutput)) bsonOutput.toByteArray } def documentEncode(something: Something): BsonDocument = { val doc = new BsonDocument() write(something, new BsonDocumentWriter(doc)) doc } def jsonEncode(something: Something): String = { val stringWriter = new StringWriter() write(something, new JsonWriter(stringWriter)) stringWriter.toString } @Benchmark def binaryEncoding(): Array[Byte] = { binaryEncode(something) } @Benchmark def documentEncoding(): BsonDocument = { documentEncode(something) } @Benchmark def jsonEncoding(): String = { jsonEncode(something) } @Benchmark def valueEncoding(): BsonValue = { BsonValueOutput.write(something) } def read(bsonReader: BsonReader): Something = { val input = new BsonReaderInput(bsonReader) Something.codec.read(input) } @Benchmark def binaryDecoding(): Something = { read(new BsonBinaryReader(ByteBuffer.wrap(bytes))) } @Benchmark def documentDecoding(): Something = { read(new BsonDocumentReader(doc)) } @Benchmark def jsonDecoding(): Something = { read(new JsonReader(json)) } }
Example 22
Source File: BsonCodecBenchmark.scala From scala-commons with MIT License | 5 votes |
package com.avsystem.commons package mongo import java.nio.ByteBuffer import com.avsystem.commons.rpc.akka.serialization.{Nested, Something} import org.bson.codecs.{BsonDocumentCodec, DecoderContext, EncoderContext} import org.bson.io.BasicOutputBuffer import org.bson.{BsonArray, BsonBinaryReader, BsonBinaryWriter, BsonDocument, BsonInt32, BsonString} import org.openjdk.jmh.annotations.{Benchmark, BenchmarkMode, Fork, Measurement, Mode, Scope, State, Warmup} @Warmup(iterations = 10) @Measurement(iterations = 20) @Fork(1) @BenchmarkMode(Array(Mode.Throughput)) @State(Scope.Thread) class BsonCodecBenchmark { import BsonCodecBenchmark._ private val something = Something(42, Nested(List(4, 8, 15, 16, 23, 42, 0), 131), "lol") private val doc = somethingCodec.toDocument(something) private val bytes = binaryEncode(something) def binaryEncode(something: Something): Array[Byte] = { val output = new BasicOutputBuffer() val writer = new BsonBinaryWriter(output) val doc = somethingCodec.toDocument(something) bsonDocumentCodec.encode(writer, doc.toBson, EncoderContext.builder().build()) output.toByteArray } @Benchmark def binaryEncoding(): Array[Byte] = { binaryEncode(something) } @Benchmark def binaryDecoding(): Something = { val reader = new BsonBinaryReader(ByteBuffer.wrap(bytes)) val doc = bsonDocumentCodec.decode(reader, DecoderContext.builder().build()) somethingCodec.fromDocument(new Doc(doc)) } @Benchmark def encoding(): Doc = { somethingCodec.toDocument(something) } @Benchmark def decoding(): Something = { somethingCodec.fromDocument(doc) } } object BsonCodecBenchmark { import BsonCodec._ val bsonDocumentCodec = new BsonDocumentCodec() val intKey: DocKey[Int, BsonInt32] = int32.key("int") val strKey: DocKey[String, BsonString] = string.key("str") val listKey: DocKey[List[Int], BsonArray] = int32.collection[List].key("list") val nestedCodec = new DocumentCodec[Nested] { override def toDocument(t: Nested): Doc = Doc() .put(listKey, t.list) .put(intKey, t.int) override def fromDocument(doc: Doc) = Nested( list = doc.require(listKey), int = doc.require(intKey) ) } val nestedKey: DocKey[Nested, BsonDocument] = nestedCodec.bsonCodec.key("nested") val somethingCodec = new DocumentCodec[Something] { override def toDocument(t: Something): Doc = Doc() .put(intKey, t.int) .put(nestedKey, t.nested) .put(strKey, t.str) override def fromDocument(doc: Doc): Something = Something( int = doc.require(intKey), nested = doc.require(nestedKey), str = doc.require(strKey) ) } }
Example 23
Source File: TestUpdateExpr.scala From gatling-grpc with Apache License 2.0 | 5 votes |
package com.github.phisgr.gatling.pb.bench import java.util.concurrent.TimeUnit import com.github.phisgr.gatling.grpc.Predef._ import com.github.phisgr.gatling.javapb._ import com.github.phisgr.gatling.pb.Test import com.github.phisgr.gatling.pb.test._ import io.gatling.commons.validation.Validation import io.gatling.core.session.{Expression, Session} import org.openjdk.jmh.annotations.{Benchmark, OutputTimeUnit} @OutputTimeUnit(TimeUnit.MILLISECONDS) class TestUpdateExpr { import TestUpdateExpr._ @Benchmark def updateSimpleExpr(): Validation[SimpleMessage] = { SimpleExpr(Session1) } @Benchmark def updateComplexExpr(): Validation[ComplexMessage] = { ComplexExpr(Session1) } @Benchmark def updateSimpleExprJava(): Validation[Test.SimpleMessage] = { SimpleExprJava(Session1) } @Benchmark def updateComplexExprJava(): Validation[Test.ComplexMessage] = { ComplexExprJava(Session1) } @Benchmark def lambdaSimpleExprJava(): Validation[Test.SimpleMessage] = { SimpleExprJavaLambda(Session1) } @Benchmark def lambdaComplexExprJava(): Validation[Test.ComplexMessage] = { ComplexExprJavaLambda(Session1) } } object TestUpdateExpr { private val SimpleExpr = SimpleMessage.defaultInstance.updateExpr( _.s :~ $("name") ) private val SimpleExprJava: Expression[Test.SimpleMessage] = Test.SimpleMessage.getDefaultInstance .update(_.setS)($("name")) private val SimpleExprJavaLambda: Expression[Test.SimpleMessage] = { s: Session => for { name <- s("name").validate[String] } yield { val builder = Test.SimpleMessage.newBuilder() builder.setS(name) builder.build() } } private val ComplexExpr = ComplexMessage.defaultInstance.updateExpr( _.m.s :~ $("name"), _.i :~ $("count"), ) private val ComplexExprJava: Expression[Test.ComplexMessage] = Test.ComplexMessage.getDefaultInstance .update(_.getMBuilder.setS)($("name")) .update(_.setI)($("count")) private val ComplexExprJavaLambda: Expression[Test.ComplexMessage] = { s: Session => for { name <- s("name").validate[String] count <- s("count").validate[Int] } yield { val builder = Test.ComplexMessage.newBuilder() builder.getMBuilder.setS(name) builder.setI(count) builder.build() } } private val Session1 = Session( scenario = "Scenario", userId = 1L, attributes = Map( "name" -> "Asdf Qwer", "count" -> 123 ), startDate = System.currentTimeMillis() ) }
Example 24
Source File: MutableSetOfIntsWriting.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.ToJson import com.rallyhealth.weepickle.v1.WeePickle.FromScala import io.circe.syntax._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import upickle.default._ class MutableSetOfIntsWriting extends MutableSetOfIntsBenchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringOutput.write(obj).getBytes(UTF_8) @Benchmark def borer(): Array[Byte] = io.bullet.borer.Json.encode(obj).toByteArray @Benchmark def circe(): Array[Byte] = printer.print(obj.asJson).getBytes(UTF_8) @Benchmark def dslJsonScala(): Array[Byte] = dslJsonEncode(obj) @Benchmark def jacksonScala(): Array[Byte] = jacksonMapper.writeValueAsBytes(obj) @Benchmark def jsoniterScala(): Array[Byte] = writeToArray(obj) @Benchmark def jsoniterScalaPrealloc(): Int = writeToSubArray(obj, preallocatedBuf, 0, preallocatedBuf.length) @Benchmark def playJson(): Array[Byte] = Json.toBytes(Json.toJson(obj)) @Benchmark def uPickle(): Array[Byte] = write(obj).getBytes(UTF_8) @Benchmark def weePickle(): Array[Byte] = FromScala(obj).transform(ToJson.bytes) }
Example 25
Source File: ArrayBufferOfBooleansWriting.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.ToJson import com.rallyhealth.weepickle.v1.WeePickle.FromScala import io.circe.syntax._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ import upickle.default._ class ArrayBufferOfBooleansWriting extends ArrayBufferOfBooleansBenchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringOutput.write(obj).getBytes(UTF_8) @Benchmark def borer(): Array[Byte] = io.bullet.borer.Json.encode(obj).toByteArray @Benchmark def circe(): Array[Byte] = printer.print(obj.asJson).getBytes(UTF_8) @Benchmark def dslJsonScala(): Array[Byte] = dslJsonEncode(obj) @Benchmark def jacksonScala(): Array[Byte] = jacksonMapper.writeValueAsBytes(obj) @Benchmark def jsoniterScala(): Array[Byte] = writeToArray(obj) @Benchmark def jsoniterScalaPrealloc(): Int = writeToSubArray(obj, preallocatedBuf, 0, preallocatedBuf.length) @Benchmark def playJson(): Array[Byte] = Json.toBytes(Json.toJson(obj)) @Benchmark def sprayJson(): Array[Byte] = obj.toJson.compactPrint.getBytes(UTF_8) @Benchmark def uPickle(): Array[Byte] = write(obj).getBytes(UTF_8) @Benchmark def weePickle(): Array[Byte] = FromScala(obj).transform(ToJson.bytes) }
Example 26
Source File: ArrayOfCharsReading.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.PlayJsonFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.FromJson import com.rallyhealth.weepickle.v1.WeePickle.ToScala import io.circe.parser._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ import upickle.default._ class ArrayOfCharsReading extends ArrayOfCharsBenchmark { @Benchmark def avSystemGenCodec(): Array[Char] = JsonStringInput.read[Array[Char]](new String(jsonBytes, UTF_8)) @Benchmark def borer(): Array[Char] = io.bullet.borer.Json.decode(jsonBytes).to[Array[Char]].value @Benchmark def circe(): Array[Char] = decode[Array[Char]](new String(jsonBytes, UTF_8)).fold(throw _, identity) @Benchmark def jacksonScala(): Array[Char] = jacksonMapper.readValue[Array[Char]](jsonBytes) @Benchmark def jsoniterScala(): Array[Char] = readFromArray[Array[Char]](jsonBytes) @Benchmark def playJson(): Array[Char] = Json.parse(jsonBytes).as[Array[Char]] @Benchmark def sprayJson(): Array[Char] = JsonParser(jsonBytes).convertTo[Array[Char]] @Benchmark def uPickle(): Array[Char] = read[Array[Char]](jsonBytes) @Benchmark def weePickle(): Array[Char] = FromJson(jsonBytes).transform(ToScala[Array[Char]]) }
Example 27
Source File: ArrayOfDurationsWriting.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.core._ import io.circe.syntax._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ class ArrayOfDurationsWriting extends ArrayOfDurationsBenchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringOutput.write(obj).getBytes(UTF_8) @Benchmark def borer(): Array[Byte] = io.bullet.borer.Json.encode(obj).toByteArray @Benchmark def circe(): Array[Byte] = printer.print(obj.asJson).getBytes(UTF_8) @Benchmark def jacksonScala(): Array[Byte] = jacksonMapper.writeValueAsBytes(obj) @Benchmark def jsoniterScala(): Array[Byte] = writeToArray(obj) @Benchmark def jsoniterScalaPrealloc(): Int = writeToSubArray(obj, preallocatedBuf, 0, preallocatedBuf.length) @Benchmark def playJson(): Array[Byte] = Json.toBytes(Json.toJson(obj)) @Benchmark def sprayJson(): Array[Byte] = obj.toJson.compactPrint.getBytes(UTF_8) @Benchmark def uPickle(): Array[Byte] = write(obj).getBytes(UTF_8) }
Example 28
Source File: ArrayOfBigDecimalsReading.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders.decodingConfig import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.core._ //import com.rallyhealth.weejson.v1.jackson.FromJson //import com.rallyhealth.weepickle.v1.WeePickle.ToScala import io.circe.parser._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ class ArrayOfBigDecimalsReading extends ArrayOfBigDecimalsBenchmark { @Benchmark def avSystemGenCodec(): Array[BigDecimal] = JsonStringInput.read[Array[BigDecimal]](new String(jsonBytes, UTF_8), jsonOptions) @Benchmark def borer(): Array[BigDecimal] = io.bullet.borer.Json.decode(jsonBytes).withConfig(decodingConfig).to[Array[BigDecimal]].value @Benchmark def circe(): Array[BigDecimal] = decode[Array[BigDecimal]](new String(jsonBytes, UTF_8)).fold(throw _, identity) @Benchmark def dslJsonScala(): Array[BigDecimal] = dslJsonDecode[Array[BigDecimal]](jsonBytes) @Benchmark def jacksonScala(): Array[BigDecimal] = jacksonMapper.readValue[Array[BigDecimal]](jsonBytes) @Benchmark def jsoniterScala(): Array[BigDecimal] = readFromArray[Array[BigDecimal]](jsonBytes) @Benchmark def playJson(): Array[BigDecimal] = Json.parse(jsonBytes).as[Array[BigDecimal]] @Benchmark def sprayJson(): Array[BigDecimal] = JsonParser(jsonBytes).convertTo[Array[BigDecimal]] @Benchmark def uPickle(): Array[BigDecimal] = read[Array[BigDecimal]](jsonBytes) }
Example 29
Source File: ArrayOfBytesWriting.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ //import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.ToJson import com.rallyhealth.weepickle.v1.WeePickle.FromScala import io.circe.syntax._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ import upickle.default._ class ArrayOfBytesWriting extends ArrayOfBytesBenchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringOutput.write(obj).getBytes(UTF_8) @Benchmark def borer(): Array[Byte] = io.bullet.borer.Json.encode(obj)(byteArrayEnc).toByteArray @Benchmark def circe(): Array[Byte] = printer.print(obj.asJson).getBytes(UTF_8) @Benchmark def jacksonScala(): Array[Byte] = jacksonByteArrayMapper.writeValueAsBytes(obj) @Benchmark def jsoniterScala(): Array[Byte] = writeToArray(obj) @Benchmark def jsoniterScalaPrealloc(): Int = writeToSubArray(obj, preallocatedBuf, 0, preallocatedBuf.length) @Benchmark def playJson(): Array[Byte] = Json.toBytes(Json.toJson(obj)) @Benchmark def sprayJson(): Array[Byte] = obj.toJson.compactPrint.getBytes(UTF_8) @Benchmark def uPickle(): Array[Byte] = write(obj).getBytes(UTF_8) @Benchmark def weePickle(): Array[Byte] = FromScala(obj)(WeePickleFromTos.fromNonBinaryByteArray).transform(ToJson.bytes) }
Example 30
Source File: ArrayOfBooleansReading.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.FromJson import com.rallyhealth.weepickle.v1.WeePickle.ToScala import io.circe.parser._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ import upickle.default._ class ArrayOfBooleansReading extends ArrayOfBooleansBenchmark { @Benchmark def avSystemGenCodec(): Array[Boolean] = JsonStringInput.read[Array[Boolean]](new String(jsonBytes, UTF_8)) @Benchmark def borer(): Array[Boolean] = io.bullet.borer.Json.decode(jsonBytes).to[Array[Boolean]].value @Benchmark def circe(): Array[Boolean] = decode[Array[Boolean]](new String(jsonBytes, UTF_8)).fold(throw _, identity) @Benchmark def dslJsonScala(): Array[Boolean] = dslJsonDecode[Array[Boolean]](jsonBytes) @Benchmark def jacksonScala(): Array[Boolean] = jacksonMapper.readValue[Array[Boolean]](jsonBytes) @Benchmark def jsoniterScala(): Array[Boolean] = readFromArray[Array[Boolean]](jsonBytes) @Benchmark def playJson(): Array[Boolean] = Json.parse(jsonBytes).as[Array[Boolean]] @Benchmark def sprayJson(): Array[Boolean] = JsonParser(jsonBytes).convertTo[Array[Boolean]] @Benchmark def uPickle(): Array[Boolean] = read[Array[Boolean]](jsonBytes) @Benchmark def weePickle(): Array[Boolean] = FromJson(jsonBytes).transform(ToScala[Array[Boolean]]) }
Example 31
Source File: ListOfBooleansWriting.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.ToJson import com.rallyhealth.weepickle.v1.WeePickle.FromScala import io.circe.syntax._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ import upickle.default._ class ListOfBooleansWriting extends ListOfBooleansBenchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringOutput.write(obj).getBytes(UTF_8) @Benchmark def borer(): Array[Byte] = io.bullet.borer.Json.encode(obj).toByteArray @Benchmark def circe(): Array[Byte] = printer.print(obj.asJson).getBytes(UTF_8) @Benchmark def dslJsonScala(): Array[Byte] = dslJsonEncode(obj) @Benchmark def jacksonScala(): Array[Byte] = jacksonMapper.writeValueAsBytes(obj) @Benchmark def jsoniterScala(): Array[Byte] = writeToArray(obj) @Benchmark def jsoniterScalaPrealloc(): Int = writeToSubArray(obj, preallocatedBuf, 0, preallocatedBuf.length) @Benchmark def playJson(): Array[Byte] = Json.toBytes(Json.toJson(obj)) @Benchmark def sprayJson(): Array[Byte] = obj.toJson.compactPrint.getBytes(UTF_8) @Benchmark def uPickle(): Array[Byte] = write(obj).getBytes(UTF_8) @Benchmark def weePickle(): Array[Byte] = FromScala(obj).transform(ToJson.bytes) }
Example 32
Source File: ArrayOfZoneOffsetsReading.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import java.time.ZoneOffset import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.PlayJsonFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.core._ import io.circe.parser._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ class ArrayOfZoneOffsetsReading extends ArrayOfZoneOffsetsBenchmark { @Benchmark def avSystemGenCodec(): Array[ZoneOffset] = JsonStringInput.read[Array[ZoneOffset]](new String(jsonBytes, UTF_8)) @Benchmark def borer(): Array[ZoneOffset] = io.bullet.borer.Json.decode(jsonBytes).to[Array[ZoneOffset]].value @Benchmark def circe(): Array[ZoneOffset] = decode[Array[ZoneOffset]](new String(jsonBytes, UTF_8)).fold(throw _, identity) @Benchmark def jacksonScala(): Array[ZoneOffset] = jacksonMapper.readValue[Array[ZoneOffset]](jsonBytes) @Benchmark def jsoniterScala(): Array[ZoneOffset] = readFromArray[Array[ZoneOffset]](jsonBytes) @Benchmark def playJson(): Array[ZoneOffset] = Json.parse(jsonBytes).as[Array[ZoneOffset]] @Benchmark def sprayJson(): Array[ZoneOffset] = JsonParser(jsonBytes).convertTo[Array[ZoneOffset]] @Benchmark def uPickle(): Array[ZoneOffset] = read[Array[ZoneOffset]](jsonBytes) }
Example 33
Source File: ArrayOfShortsReading.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.FromJson import com.rallyhealth.weepickle.v1.WeePickle.ToScala import io.circe.parser._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ import upickle.default._ class ArrayOfShortsReading extends ArrayOfShortsBenchmark { @Benchmark def avSystemGenCodec(): Array[Short] = JsonStringInput.read[Array[Short]](new String(jsonBytes, UTF_8)) @Benchmark def borer(): Array[Short] = io.bullet.borer.Json.decode(jsonBytes).to[Array[Short]].value @Benchmark def circe(): Array[Short] = decode[Array[Short]](new String(jsonBytes, UTF_8)).fold(throw _, identity) @Benchmark def dslJsonScala(): Array[Short] = dslJsonDecode[Array[Short]](jsonBytes) @Benchmark def jacksonScala(): Array[Short] = jacksonMapper.readValue[Array[Short]](jsonBytes) @Benchmark def jsoniterScala(): Array[Short] = readFromArray[Array[Short]](jsonBytes) @Benchmark def playJson(): Array[Short] = Json.parse(jsonBytes).as[Array[Short]] @Benchmark def sprayJson(): Array[Short] = JsonParser(jsonBytes).convertTo[Array[Short]] @Benchmark def uPickle(): Array[Short] = read[Array[Short]](jsonBytes) @Benchmark def weePickle(): Array[Short] = FromJson(jsonBytes).transform(ToScala[Array[Short]]) }
Example 34
Source File: AcsBench.scala From daml with Apache License 2.0 | 5 votes |
// Copyright (c) 2020 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. // SPDX-License-Identifier: Apache-2.0 package com.daml.platform.sandbox.perf import java.io.File import akka.stream.scaladsl.Sink import com.daml.bazeltools.BazelRunfiles._ import com.daml.ledger.api.domain import com.daml.ledger.api.testing.utils.MockMessages import com.daml.ledger.api.v1.active_contracts_service.GetActiveContractsResponse import com.daml.ledger.api.v1.command_service.SubmitAndWaitRequest import com.daml.ledger.api.v1.event.CreatedEvent import com.daml.ledger.api.v1.value.Identifier import com.daml.ledger.client.services.acs.ActiveContractSetClient import com.daml.platform.sandbox.services.TestCommands import org.openjdk.jmh.annotations.{Benchmark, Level, Setup} class AcsBenchState extends PerfBenchState with DummyCommands with InfAwait { def commandCount = 10000L @Setup(Level.Invocation) def submitCommands(): Unit = { await( dummyCreates(ledger.ledgerId) .take(commandCount) .mapAsync(100)(ledger.commandService.submitAndWait) .runWith(Sink.ignore)(mat)) () } } class AcsBench extends TestCommands with InfAwait { override protected def darFile: File = new File(rlocation("ledger/test-common/model-tests.dar")) private def generateCommand( sequenceNumber: Int, contractId: String, ledgerId: domain.LedgerId, template: Identifier): SubmitAndWaitRequest = { buildRequest( ledgerId = ledgerId, commandId = s"command-id-exercise-$sequenceNumber", commands = Seq(exerciseWithUnit(template, contractId, "DummyChoice1")), appId = "app1" ).toSync } private def extractContractId( response: GetActiveContractsResponse, template: Identifier): Option[String] = { val events = response.activeContracts.toSet events.collectFirst { case CreatedEvent(contractId, _, Some(id), _, _, _, _, _, _) if id == template => contractId } } private def getContractIds( state: PerfBenchState, template: Identifier, ledgerId: domain.LedgerId) = new ActiveContractSetClient(ledgerId, state.ledger.acsService)(state.esf) .getActiveContracts(MockMessages.transactionFilter) .map(extractContractId(_, template)) @Benchmark def consumeAcs(state: AcsBenchState): Unit = { val ledgerId = state.ledger.ledgerId val template = templateIds.dummy await( getContractIds(state, template, ledgerId).zipWithIndex .collect { case (Some(contractId), i) => generateCommand(i.toInt, contractId, ledgerId, template) } .mapAsync(100)(state.ledger.commandService.submitAndWait) .runWith(Sink.ignore)(state.mat)) () } }
Example 35
Source File: SimpleBench.scala From daml with Apache License 2.0 | 5 votes |
// Copyright (c) 2020 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. // SPDX-License-Identifier: Apache-2.0 package com.daml.platform.sandbox.perf import java.io.File import akka.stream.scaladsl.Sink import com.daml.bazeltools.BazelRunfiles._ import org.openjdk.jmh.annotations.Benchmark class SimpleBenchState extends PerfBenchState with DummyCommands with InfAwait class SimpleBench extends DummyCommands with InfAwait { override protected def darFile: File = new File(rlocation("ledger/test-common/model-tests.dar")) @Benchmark def ingest10kCommands(state: SimpleBenchState): Unit = { val commandCount = 10000L await( dummyCreates(state.ledger.ledgerId) .take(commandCount) .mapAsync(100)(state.ledger.commandService.submitAndWait _) .runWith(Sink.ignore)(state.mat)) () } }
Example 36
Source File: KVStoreBenchmark.scala From iotchain with MIT License | 5 votes |
package jbok.benchmark import cats.effect.IO import org.openjdk.jmh.annotations.{Benchmark, OperationsPerInvocation, TearDown} import org.scalacheck.Gen import cats.implicits._ import jbok.common.{gen, FileUtil} import jbok.core.StatelessGen import jbok.persistent.{ColumnFamily, MemoryKVStore} import jbok.persistent.rocksdb.RocksKVStore class KVStoreBenchmark extends JbokBenchmark { val size = 10000 val blockHeaders = Gen.listOfN(size, StatelessGen.blockHeader).sample.get.toArray var i = 0 val keyGen = gen.sizedByteArray(16) val valueGen = gen.sizedByteArray(100) val keys = Gen.listOfN(size, keyGen).sample.get val values = Gen.listOfN(size, valueGen).sample.get val kvs = keys.zip(values).toArray val dirRocks = FileUtil[IO].temporaryDir().allocated.unsafeRunSync()._1 val (dbRocks, close) = RocksKVStore.resource[IO](dirRocks.path, List(ColumnFamily.default)).allocated.unsafeRunSync() var dbMem = MemoryKVStore[IO].unsafeRunSync() @Benchmark def putRocks() = { val (k, v) = kvs(i) i = (i + 1) % kvs.length dbRocks.put(ColumnFamily.default, k, v).unsafeRunSync() } @Benchmark @OperationsPerInvocation(100) def putBatchRocks() = { i = (i + 1) % (kvs.length / 100) val put = (i * 100 until (i + 1) * 100) .map(i => kvs(i)) .toList dbRocks.writeBatch(ColumnFamily.default, put, Nil).unsafeRunSync() } @Benchmark @OperationsPerInvocation(100) def putBatchRocksPar() = { i = (i + 1) % (kvs.length / 100) val put = (i * 100 until (i + 1) * 100) .map(i => kvs(i)) .toList put.parTraverse { case (k, v) => dbRocks.put(ColumnFamily.default, k, v) }.unsafeRunSync() } @TearDown def tearDown(): Unit = { close.unsafeRunSync() dbMem = MemoryKVStore[IO].unsafeRunSync() RocksKVStore.destroy[IO](dirRocks.path).unsafeRunSync() } }
Example 37
Source File: SignatureBenchmark.scala From iotchain with MIT License | 5 votes |
package jbok.benchmark import cats.effect.IO import fs2._ import jbok.crypto._ import jbok.crypto.signature.{ECDSA, Signature} import org.openjdk.jmh.annotations.{Benchmark, OperationsPerInvocation} class SignatureBenchmark extends JbokBenchmark { val s = "hash benchmark" val b = s.utf8bytes val h = b.kec256.toArray val k = Signature[ECDSA].generateKeyPair[IO]().unsafeRunSync() val chainId: BigInt = 1 val sig = Signature[ECDSA].sign[IO](h, k, chainId).unsafeRunSync() @Benchmark @OperationsPerInvocation(100) def signSecp256k1() = (0 until 100).foreach(_ => Signature[ECDSA].sign[IO](h, k, chainId).unsafeRunSync()) @Benchmark @OperationsPerInvocation(100) def signSecp256k1Parallel() = Stream .range(0, 100) .covary[IO] .mapAsyncUnordered(4)(_ => Signature[ECDSA].sign[IO](h, k, chainId)) .compile .drain .unsafeRunSync() @Benchmark def verifySecp256k1() = Signature[ECDSA].verify[IO](h, sig, k.public, chainId).unsafeRunSync() @Benchmark def recoverSecp256k1() = Signature[ECDSA].recoverPublic(h, sig, chainId) }
Example 38
Source File: HashBenchmark.scala From iotchain with MIT License | 5 votes |
package jbok.benchmark import org.openjdk.jmh.annotations.Benchmark import jbok.crypto._ class HashBenchmark extends JbokBenchmark { val s = "hash benchmark" val b = s.utf8bytes @Benchmark def kec256() = { b.kec256 } @Benchmark def ripemd160() = { b.ripemd160 } @Benchmark def kec512() = { b.kec512 } @Benchmark def sha256() = { b.sha256 } }
Example 39
Source File: PrecompiledContractBenchmark.scala From iotchain with MIT License | 5 votes |
package jbok.benchmark.evm import jbok.benchmark.JbokBenchmark import jbok.evm.PrecompiledContracts._ import org.openjdk.jmh.annotations.Benchmark import scodec.bits._ class PrecompiledContractBenchmark extends JbokBenchmark { val input = hex"38d18acb67d25c8bb9942764b62f18e17054f66a817bd4295423adf9ed98873e000000000000000000000000000000000000000000000000000000000000001b38d18acb67d25c8bb9942764b62f18e17054f66a817bd4295423adf9ed98873e789d1dd423d25f0772d2748d60f7e4b81bb14d086eba8e8e8efb6dcff8a4ae02" val expModInput = hex"00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002003fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2efffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f" val bn256AddInput = hex"18b18acfb4c2c30276db5411368e7185b311dd124691610c5d3b74034e093dc9063c909c4720840cb5134cb9f59fa749755796819658d32efc0d288198f3726607c2b7f58a84bd6145f00c9c2bc0bb1a187f20ff2c92963a88019e7c6a014eed06614e20c147e940f2d70da3f74c9a17df361706a4485c742bd6788478fa17d7" val bn256MulInput = hex"2bd3e6d0f3b142924f5ca7b49ce5b9d54c4703d7ae5648e61d02268b1a0a9fb721611ce0a6af85915e2f1d70300909ce2e49dfad4a4619c8390cae66cefdb20400000000000000000000000000000000000000000000000011138ce750fa15c2" val bn256PairingInput = hex"1c76476f4def4bb94541d57ebba1193381ffa7aa76ada664dd31c16024c43f593034dd2920f673e204fee2811c678745fc819b55d3e9d294e45c9b03a76aef41209dd15ebff5d46c4bd888e51a93cf99a7329636c63514396b4a452003a35bf704bf11ca01483bfa8b34b43561848d28905960114c8ac04049af4b6315a416782bb8324af6cfc93537a2ad1a445cfd0ca2a71acd7ac41fadbf933c2a51be344d120a2a4cf30c1bf9845f20c6fe39e07ea2cce61f0c9bb048165fe5e4de877550111e129f1cf1097710d41c4ac70fcdfa5ba2023c6ff1cbeac322de49d1b6df7c2032c61a830e3c17286de9462bf242fca2883585b93870a73853face6a6bf411198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa" @Benchmark def ecRecovery() = EllipticCurveRecovery.exec(input) @Benchmark def identity() = Identity.exec(input) @Benchmark def ripemd160() = Ripemd160.exec(input) @Benchmark def sha256() = Sha256.exec(input) @Benchmark def expMod() = ExpMod.exec(expModInput) @Benchmark def bN256Add() = BN256Add.exec(bn256AddInput) @Benchmark def bN256Mul() = BN256Mul.exec(bn256MulInput) @Benchmark def bN256Pairing() = BN256Pairing.exec(bn256PairingInput) }
Example 40
Source File: BN256Benchmark.scala From iotchain with MIT License | 5 votes |
package jbok.benchmark import jbok.crypto.bn256._ import org.openjdk.jmh.annotations.Benchmark class BN256Benchmark extends JbokBenchmark { val fp2 = Fp2(BigInt("239846234862342323958623"), BigInt("2359862352529835623")) val fp12 = Fp12( Fp6( Fp2(BigInt("239846234862342323958623"), BigInt("2359862352529835623")), Fp2(BigInt("928836523"), BigInt("9856234")), Fp2(BigInt("235635286"), BigInt("5628392833")) ), Fp6( Fp2(BigInt("252936598265329856238956532167968"), BigInt("23596239865236954178968")), Fp2(BigInt("95421692834"), BigInt("236548")), Fp2(BigInt("924523"), BigInt("12954623")) ) ) val g1 = CurvePoint.curveGen * BigInt("21888242871839275222246405745257275088548364400416034343698204186575808495616") val g2 = TwistPoint.twistGen * BigInt("21888242871839275222246405745257275088548364400416034343698204186575808495616") @Benchmark def Fp12Square() = fp12.square() @Benchmark def Fp12SquareByMul() = fp12 * fp12 @Benchmark def Fp2Add() = fp2 + fp2 @Benchmark def Fp2AddByMul() = fp2 * 2 @Benchmark def Fp2Square() = fp2.square() @Benchmark def Fp2SquareByMul() = fp2 * fp2 @Benchmark def G1AddG1() = g1 + g1 @Benchmark def G1MulBigInt() = g1 * BigInt("123456789") @Benchmark def pair() = BN256.pair(g1, g2) }
Example 41
Source File: RefineVBenchmark.scala From refined with MIT License | 5 votes |
package eu.timepit.refined.benchmark import eu.timepit.refined.api.Refined import eu.timepit.refined.numeric.Positive import eu.timepit.refined.refineV import eu.timepit.refined.string.Regex import java.util.concurrent.TimeUnit import org.openjdk.jmh.annotations.{Benchmark, BenchmarkMode, Mode, OutputTimeUnit} @BenchmarkMode(Array(Mode.AverageTime)) class RefineVBenchmark { @Benchmark @OutputTimeUnit(TimeUnit.NANOSECONDS) def refineV_Positive: Either[String, Int Refined Positive] = refineV[Positive](1) @Benchmark @OutputTimeUnit(TimeUnit.NANOSECONDS) def refineV_Regex: Either[String, String Refined Regex] = refineV[Regex](".*") }
Example 42
Source File: SnapshotAssemblerBench.scala From EncryCore with GNU General Public License v3.0 | 5 votes |
package benches import java.io.File import java.util.concurrent.TimeUnit import benches.SnapshotAssemblerBench.SnapshotAssemblerBenchState import encry.view.state.avlTree.utils.implicits.Instances._ import benches.StateBenches.{StateBenchState, benchSettings} import benches.Utils.{getRandomTempDir, utxoFromBoxHolder} import encry.settings.Settings import encry.storage.{RootNodesStorage, VersionalStorage} import encry.storage.VersionalStorage.{StorageKey, StorageValue, StorageVersion} import encry.storage.levelDb.versionalLevelDB.{LevelDbFactory, VLDBWrapper, VersionalLevelDBCompanion} import encry.utils.FileHelper import encry.view.fast.sync.SnapshotHolder import encry.view.state.UtxoState import encry.view.state.avlTree.AvlTree import org.encryfoundation.common.utils.TaggedTypes.Height import org.iq80.leveldb.{DB, Options} import org.openjdk.jmh.annotations.{Benchmark, Mode, Scope, State} import org.openjdk.jmh.infra.Blackhole import org.openjdk.jmh.profile.GCProfiler import org.openjdk.jmh.runner.{Runner, RunnerException} import org.openjdk.jmh.runner.options.{OptionsBuilder, TimeValue, VerboseMode} import scorex.utils.Random class SnapshotAssemblerBench { @Benchmark def createTree(stateBench: SnapshotAssemblerBenchState, bh: Blackhole): Unit = { bh.consume { //stateBench.a.initializeSnapshotData(stateBench.block1) } } } object SnapshotAssemblerBench { @throws[RunnerException] def main(args: Array[String]): Unit = { val opt = new OptionsBuilder() .include(".*" + classOf[SnapshotAssemblerBench].getSimpleName + ".*") .forks(1) .threads(1) .warmupIterations(benchSettings.benchesSettings.warmUpIterations) .measurementIterations(benchSettings.benchesSettings.measurementIterations) .mode(Mode.AverageTime) .timeUnit(TimeUnit.SECONDS) .verbosity(VerboseMode.EXTRA) .addProfiler(classOf[GCProfiler]) .warmupTime(TimeValue.milliseconds(benchSettings.benchesSettings.warmUpTime)) .measurementTime(TimeValue.milliseconds(benchSettings.benchesSettings.measurementTime)) .build new Runner(opt).run } @State(Scope.Benchmark) class SnapshotAssemblerBenchState extends Settings { val a: AvlTree[StorageKey, StorageValue] = createAvl("9gKDVmfsA6J4b78jDBx6JmS86Zph98NnjnUqTJBkW7zitQMReia", 0, 500000) val block1 = Utils.generateGenesisBlock(Height @@ 1) def createAvl(address: String, from: Int, to: Int): AvlTree[StorageKey, StorageValue] = { val firstDir: File = FileHelper.getRandomTempDir val firstStorage: VLDBWrapper = { val levelDBInit = LevelDbFactory.factory.open(firstDir, new Options) VLDBWrapper(VersionalLevelDBCompanion(levelDBInit, settings.levelDB, keySize = 32)) } val dir: File = FileHelper.getRandomTempDir val levelDb: DB = LevelDbFactory.factory.open(dir, new Options) val rootNodesStorage = RootNodesStorage[StorageKey, StorageValue](levelDb, 10, dir) val firstAvl: AvlTree[StorageKey, StorageValue] = AvlTree[StorageKey, StorageValue](firstStorage, rootNodesStorage) val avlNew = (from to to).foldLeft(firstAvl) { case (avl, i) => val bx = Utils.genAssetBox(address, i, nonce = i) val b = (StorageKey !@@ bx.id, StorageValue @@ bx.bytes) avl.insertAndDeleteMany(StorageVersion @@ Random.randomBytes(), List(b), List.empty) } avlNew } def tmpDir: File = FileHelper.getRandomTempDir } }
Example 43
Source File: StateRollbackBench.scala From EncryCore with GNU General Public License v3.0 | 5 votes |
package benches import java.io.File import java.util.concurrent.TimeUnit import benches.StateRollbackBench.StateRollbackState import benches.Utils._ import encry.storage.VersionalStorage import encry.utils.CoreTaggedTypes.VersionTag import encry.view.state.{BoxHolder, UtxoState} import encryBenchmark.{BenchSettings, Settings} import org.encryfoundation.common.modifiers.history.Block import org.encryfoundation.common.modifiers.state.box.AssetBox import org.encryfoundation.common.utils.TaggedTypes.{ADKey, Difficulty} import org.openjdk.jmh.annotations.{Benchmark, Mode, Scope, State} import org.openjdk.jmh.infra.Blackhole import org.openjdk.jmh.profile.GCProfiler import org.openjdk.jmh.runner.{Runner, RunnerException} import org.openjdk.jmh.runner.options.{OptionsBuilder, TimeValue, VerboseMode} class StateRollbackBench { @Benchmark def applyBlocksToTheState(stateBench: StateRollbackState, bh: Blackhole): Unit = { bh.consume { val innerState: UtxoState = utxoFromBoxHolder(stateBench.boxesHolder, getRandomTempDir, None, stateBench.settings, VersionalStorage.IODB) val newState = stateBench.chain.foldLeft(innerState -> List.empty[VersionTag]) { case ((state, rootHashes), block) => val newState = state.applyModifier(block).right.get newState -> (rootHashes :+ newState.version) } val stateAfterRollback = newState._1.rollbackTo(newState._2.dropRight(1).last, List.empty).get val stateAfterForkBlockApplying = stateAfterRollback.applyModifier(stateBench.forkBlocks.last).right.get stateAfterForkBlockApplying.close() } } } object StateRollbackBench extends BenchSettings { @throws[RunnerException] def main(args: Array[String]): Unit = { val opt = new OptionsBuilder() .include(".*" + classOf[StateRollbackBench].getSimpleName + ".*") .forks(1) .threads(1) .warmupIterations(benchSettings.benchesSettings.warmUpIterations) .measurementIterations(benchSettings.benchesSettings.measurementIterations) .mode(Mode.AverageTime) .timeUnit(TimeUnit.SECONDS) .verbosity(VerboseMode.EXTRA) .addProfiler(classOf[GCProfiler]) .warmupTime(TimeValue.milliseconds(benchSettings.benchesSettings.warmUpTime)) .measurementTime(TimeValue.milliseconds(benchSettings.benchesSettings.measurementTime)) .build new Runner(opt).run } @State(Scope.Benchmark) class StateRollbackState extends encry.settings.Settings { val tmpDir: File = getRandomTempDir val initialBoxes: IndexedSeq[AssetBox] = (0 until benchSettings.stateBenchSettings.totalBoxesNumber).map(nonce => genHardcodedBox(privKey.publicImage.address.address, nonce) ) val boxesHolder: BoxHolder = BoxHolder(initialBoxes) var state: UtxoState = utxoFromBoxHolder(boxesHolder, tmpDir, None, settings, VersionalStorage.LevelDB) val genesisBlock: Block = generateGenesisBlockValidForState(state) state = state.applyModifier(genesisBlock).right.get val stateGenerationResults: (List[(Block, Block)], Block, UtxoState, IndexedSeq[AssetBox]) = (0 until benchSettings.stateBenchSettings.blocksNumber).foldLeft(List.empty[(Block, Block)], genesisBlock, state, initialBoxes) { case ((blocks, block, stateL, boxes), _) => val nextBlockMainChain: Block = generateNextBlockForStateWithSpendingAllPreviousBoxes( block, stateL, block.payload.txs.flatMap(_.newBoxes.map(_.asInstanceOf[AssetBox])).toIndexedSeq) val nextBlockFork: Block = generateNextBlockForStateWithSpendingAllPreviousBoxes( block, stateL, block.payload.txs.flatMap(_.newBoxes.map(_.asInstanceOf[AssetBox])).toIndexedSeq, addDiff = Difficulty @@ BigInt(100) ) val stateN: UtxoState = stateL.applyModifier(nextBlockMainChain).right.get (blocks :+ (nextBlockMainChain, nextBlockFork), nextBlockMainChain, stateN, boxes.drop( benchSettings.stateBenchSettings.transactionsNumberInEachBlock * benchSettings.stateBenchSettings.numberOfInputsInOneTransaction) ) } val chain: List[Block] = genesisBlock +: stateGenerationResults._1.map(_._1) val forkBlocks: List[Block] = genesisBlock +: stateGenerationResults._1.map(_._2) state = stateGenerationResults._3 state.close() } }
Example 44
Source File: VersionalLevelDBBanches.scala From EncryCore with GNU General Public License v3.0 | 5 votes |
package benches import java.util.concurrent.TimeUnit import benches.VersionalLevelDBBanches.VersionalLevelDBState import encry.settings.LevelDBSettings import encry.storage.levelDb.versionalLevelDB.{LevelDbFactory, VersionalLevelDBCompanion} import encry.utils.FileHelper import org.iq80.leveldb.Options import org.openjdk.jmh.annotations.{Benchmark, Mode, Scope, State} import org.openjdk.jmh.infra.Blackhole import org.openjdk.jmh.profile.GCProfiler import org.openjdk.jmh.runner.options.{OptionsBuilder, TimeValue, VerboseMode} import org.openjdk.jmh.runner.{Runner, RunnerException} class VersionalLevelDBBanches { @Benchmark def versionalLevelDbInsertion(benchStateHistory: VersionalLevelDBState, bh: Blackhole): Unit = { bh.consume { val tempDir = FileHelper.getRandomTempDir val levelDBInit = LevelDbFactory.factory.open(tempDir, new Options) val vldbInit = VersionalLevelDBCompanion(levelDBInit, LevelDBSettings(100)) benchStateHistory.elems10k.foreach(vldbInit.insert) vldbInit.close() } } } object VersionalLevelDBBanches { @throws[RunnerException] def main(args: Array[String]): Unit = { val opt = new OptionsBuilder() .include(".*" + classOf[VersionalLevelDBBanches].getSimpleName + ".*") .forks(1) .threads(2) .warmupIterations(1) .measurementIterations(1) .mode(Mode.AverageTime) .timeUnit(TimeUnit.SECONDS) .verbosity(VerboseMode.EXTRA) .addProfiler(classOf[GCProfiler]) .warmupTime(TimeValue.milliseconds(500)) .measurementTime(TimeValue.minutes(5)) .build new Runner(opt).run } @State(Scope.Benchmark) class VersionalLevelDBState { //val elems1k = Utils.generateRandomLevelDbElemsWithoutDeletions(1000, 100) //val elems5k = Utils.generateRandomLevelDbElemsWithoutDeletions(5000, 100) val elems10k = Utils.generateRandomLevelDbElemsWithoutDeletions(10000, 100) //val elems30k = Utils.generateRandomLevelDbElemsWithoutDeletions(30000, 100) } }
Example 45
Source File: ArrowsStdlib.scala From arrows with Apache License 2.0 | 5 votes |
package benchmarks import scala.concurrent.ExecutionContext.Implicits.global import arrows.stdlib.Arrow import arrows.stdlib.Task import org.openjdk.jmh.annotations.Benchmark import org.openjdk.jmh.annotations.Benchmark import scala.util.Try import scala.concurrent.Promise import scala.concurrent.Await import scala.concurrent.duration.Duration trait ArrowsStdlib { this: Benchmarks => private[this] final val arrowGen = ArrowsStdlibArrowGen(dist) private[this] final val taskGen = ArrowsStdlibTaskGen(dist) @Benchmark def arrowsStdlibArrow = { Try(Await.result(arrowGen.run(1), Duration.Inf)) } @Benchmark def arrowsStdlibTask = { Try(Await.result(taskGen(1).run, Duration.Inf)) } } object ArrowsStdlibTaskGen extends Gen[Int => Task[Int]] { def sync = Task.successful _ def async(schedule: Runnable => Unit) = { v => val p = Promise[Int]() schedule(() => p.success(v)) Task.async(p.future) } def failure(ex: Throwable) = v => Task.failed(ex) def map(t: Int => Task[Int], f: Int => Int) = t.andThen(_.map(f)) def flatMap(t: Int => Task[Int], f: Int => Task[Int]) = t.andThen(_.flatMap(f)) def handle(t: Int => Task[Int], i: Int) = t.andThen(_.recover { case _ => i }) } object ArrowsStdlibArrowGen extends Gen[Arrow[Int, Int]] { def sync = Arrow[Int] def async(schedule: Runnable => Unit) = Arrow[Int].flatMap { v => val p = Promise[Int]() schedule(() => p.success(v)) Task.async(p.future) } def failure(ex: Throwable) = Arrow.failed(ex) def map(t: Arrow[Int, Int], f: Int => Int) = t.map(f) def flatMap(t: Arrow[Int, Int], f: Arrow[Int, Int]) = t.flatMap(f) def handle(t: Arrow[Int, Int], i: Int) = t.recover { case _ => i } }
Example 46
Source File: ArrowsTwitter.scala From arrows with Apache License 2.0 | 5 votes |
package benchmarks import com.twitter.util.Promise import arrows.twitter.Arrow import arrows.twitter.Task import org.openjdk.jmh.annotations.Benchmark import org.openjdk.jmh.annotations.Benchmark import com.twitter.util.Await import scala.util.Try trait ArrowsTwitter { this: Benchmarks => private[this] final val arrowGen = ArrowsTwitterArrowGen(dist) private[this] final val taskGen = ArrowsTwitterTaskGen(dist) @Benchmark def arrowsTwitterArrow = { Try(Await.result(arrowGen.run(1))) } @Benchmark def arrowsTwitterTask = { Try(Await.result(taskGen(1).run)) } } object ArrowsTwitterTaskGen extends Gen[Int => Task[Int]] { def sync = Task.value _ def async(schedule: Runnable => Unit) = { v => val p = new Promise[Int] with Runnable { override def run() = setValue(v) } schedule(p) Task.async(p) } def failure(ex: Throwable) = v => Task.exception(ex) def map(t: Int => Task[Int], f: Int => Int) = t.andThen(_.map(f)) def flatMap(t: Int => Task[Int], f: Int => Task[Int]) = t.andThen(_.flatMap(f)) def handle(t: Int => Task[Int], i: Int) = t.andThen(_.handle { case _ => i }) } object ArrowsTwitterArrowGen extends Gen[Arrow[Int, Int]] { def sync = Arrow[Int] def async(schedule: Runnable => Unit) = Arrow[Int].flatMap { v => val p = new Promise[Int] with Runnable { override def run() = setValue(v) } schedule(p) Task.async(p) } def failure(ex: Throwable) = Arrow.exception(ex) def map(t: Arrow[Int, Int], f: Int => Int) = t.map(f) def flatMap(t: Arrow[Int, Int], f: Arrow[Int, Int]) = t.flatMap(f) def handle(t: Arrow[Int, Int], i: Int) = t.handle { case _ => i } }
Example 47
Source File: ScalaFuture.scala From arrows with Apache License 2.0 | 5 votes |
package benchmarks import scala.concurrent.ExecutionContext.Implicits.global import scala.concurrent.Future import scala.concurrent.Promise import org.openjdk.jmh.annotations.Benchmark import scala.util.Try trait ScalaFuture { this: Benchmarks => private[this] final val sFut = ScalaFutureGen(dist) @Benchmark def scalaFuture = { import scala.concurrent._ import scala.concurrent.duration._ Try(Await.result(sFut(1), Duration.Inf)) } } object ScalaFutureGen extends Gen[Int => Future[Int]] { def sync = Future.successful _ def async(schedule: Runnable => Unit) = { v => val p = Promise[Int]() schedule(() => p.success(v)) p.future } def failure(ex: Throwable) = _ => Future.failed(ex) def map(t: Int => Future[Int], f: Int => Int) = t.andThen(_.map(f)) def flatMap(t: Int => Future[Int], f: Int => Future[Int]) = t.andThen(_.flatMap(f)) def handle(t: Int => Future[Int], i: Int) = t.andThen(_.recover { case _ => i }) }
Example 48
Source File: Monix.scala From arrows with Apache License 2.0 | 5 votes |
package benchmarks import monix.eval.Task import monix.execution.Cancelable import org.openjdk.jmh.annotations.Benchmark import scala.util.Try import scala.util.Success trait MonixAsync { this: Benchmarks => private[this] final val gen = MonixGen(dist) @Benchmark def monixTask = { import scala.concurrent._ import scala.concurrent.duration._ import monix.execution.Scheduler.Implicits.global Try(Await.result(gen(1).runAsync, Duration.Inf)) } } trait MonixSync { this: Benchmarks => private[this] final val gen = MonixGen(dist) @Benchmark def monixTask = { import monix.execution.Scheduler.Implicits.global Success(gen(1).runSyncMaybe.right.get) } } object MonixGen extends Gen[Int => Task[Int]] { def sync = Task.now _ def async(schedule: Runnable => Unit) = { v => Task.async[Int] { case (s, cb) => schedule(() => cb.onSuccess(v)) Cancelable.empty } } def failure(ex: Throwable) = _ => Task.raiseError(ex) def map(t: Int => Task[Int], f: Int => Int) = t.andThen(_.map(f)) def flatMap(t: Int => Task[Int], f: Int => Task[Int]) = t.andThen(_.flatMap(f)) def handle(t: Int => Task[Int], i: Int) = t.andThen(_.onErrorHandle(_ => i)) }
Example 49
Source File: TwitterFuture.scala From arrows with Apache License 2.0 | 5 votes |
package benchmarks import com.twitter.util.Promise import com.twitter.util.Future import org.openjdk.jmh.annotations.Benchmark import scala.util.Try trait TwitterFuture { this: Benchmarks => private[this] final val gen = TwitterFutureGen(dist) @Benchmark def twitterFuture = { import com.twitter.util.Await Try(Await.result(gen(1))) } } object TwitterFutureGen extends Gen[Int => Future[Int]] { def sync = Future.value _ def async(schedule: Runnable => Unit) = { v => val p = Promise.apply[Int]() schedule(() => p.setValue(v)) p } def failure(ex: Throwable) = _ => Future.exception(ex) def map(t: Int => Future[Int], f: Int => Int) = t.andThen(_.map(f(_))) def flatMap(t: Int => Future[Int], f: Int => Future[Int]) = t.andThen(_.flatMap(f)) def handle(t: Int => Future[Int], i: Int) = t.andThen(_.handle { case _ => i }) }
Example 50
Source File: FiberRefBenchmarks.scala From zio with Apache License 2.0 | 5 votes |
package zio import java.util.concurrent.TimeUnit import org.openjdk.jmh.annotations.Benchmark import org.openjdk.jmh.annotations.BenchmarkMode import org.openjdk.jmh.annotations.Fork import org.openjdk.jmh.annotations.Measurement import org.openjdk.jmh.annotations.Mode import org.openjdk.jmh.annotations.OutputTimeUnit import org.openjdk.jmh.annotations.Param import org.openjdk.jmh.annotations.Scope import org.openjdk.jmh.annotations.State import org.openjdk.jmh.annotations.Threads import org.openjdk.jmh.annotations.Warmup import zio.IOBenchmarks.verify @State(Scope.Thread) @BenchmarkMode(Array(Mode.Throughput)) @OutputTimeUnit(TimeUnit.SECONDS) @Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) @Fork(1) @Threads(1) class FiberRefBenchmarks { @Param(Array("32")) var n: Int = _ @Benchmark def tracedCreateUpdateAndRead(): Unit = createUpdateAndRead(IOBenchmarks.TracedRuntime) @Benchmark def unTracedCreateUpdateAndRead(): Unit = createUpdateAndRead(IOBenchmarks) @Benchmark def unTracedJustYield(): Unit = justYield(IOBenchmarks) @Benchmark def unTracedCreateFiberRefsAndYield(): Unit = createFiberRefsAndYield(IOBenchmarks) private def justYield(runtime: Runtime[Any]) = runtime.unsafeRun { for { _ <- ZIO.foreach_(1.to(n))(_ => ZIO.yieldNow) } yield () } private def createFiberRefsAndYield(runtime: Runtime[Any]) = runtime.unsafeRun { for { fiberRefs <- ZIO.foreach(1.to(n))(i => FiberRef.make(i)) _ <- ZIO.foreach_(1.to(n))(_ => ZIO.yieldNow) values <- ZIO.foreachPar(fiberRefs)(_.get) _ <- verify(values == 1.to(n))(s"Got $values") } yield () } private def createUpdateAndRead(runtime: Runtime[Any]) = runtime.unsafeRun { for { fiberRefs <- ZIO.foreach(1.to(n))(i => FiberRef.make(i)) values1 <- ZIO.foreachPar(fiberRefs)(ref => ref.update(-_) *> ref.get) values2 <- ZIO.foreachPar(fiberRefs)(_.get) _ <- verify(values1.forall(_ < 0) && values1.size == values2.size)( s"Got \nvalues1: $values1, \nvalues2: $values2" ) } yield () } }
Example 51
Source File: ScalaReadBenchmark.scala From filo with Apache License 2.0 | 5 votes |
package org.velvia.filo import org.openjdk.jmh.annotations.Benchmark import org.openjdk.jmh.annotations.BenchmarkMode import org.openjdk.jmh.annotations.{Mode, State, Scope} import org.openjdk.jmh.annotations.OutputTimeUnit import scalaxy.loops._ import scala.language.postfixOps import java.util.concurrent.TimeUnit @State(Scope.Thread) class ScalaReadBenchmark { // Ok, create an IntColumn and benchmark it. val numValues = 10000 val randomInts = (0 until numValues).map(i => util.Random.nextInt) val randomIntsAray = randomInts.toArray // Scala Seq sum @Benchmark @BenchmarkMode(Array(Mode.AverageTime)) @OutputTimeUnit(TimeUnit.MICROSECONDS) def sumAllIntsScalaSeqFoldLeft(): Int = { randomInts.foldLeft(0)(_ + _) } @Benchmark @BenchmarkMode(Array(Mode.AverageTime)) @OutputTimeUnit(TimeUnit.MICROSECONDS) def sumAllIntsScalaArrayFoldLeft(): Int = { randomIntsAray.foldLeft(0)(_ + _) } @Benchmark @BenchmarkMode(Array(Mode.AverageTime)) @OutputTimeUnit(TimeUnit.MICROSECONDS) def sumAllIntsScalaArrayWhileLoop(): Int = { var total = 0 for { i <- 0 until numValues optimized } { total += randomIntsAray(i) } total } }
Example 52
Source File: DictStringBenchmark.scala From filo with Apache License 2.0 | 5 votes |
package org.velvia.filo import org.openjdk.jmh.annotations.Benchmark import org.openjdk.jmh.annotations.BenchmarkMode import org.openjdk.jmh.annotations.{Mode, State, Scope} import org.openjdk.jmh.annotations.OutputTimeUnit import scalaxy.loops._ import scala.language.postfixOps import java.util.concurrent.TimeUnit @State(Scope.Thread) class DictStringBenchmark { import scala.util.Random.{alphanumeric, nextInt, nextFloat} import VectorReader._ val numValues = 10000 // NOTE: results show that time spent is heavily influenced by ratio of unique strings... val numUniqueStrings = 500 val maxStringLength = 15 val minStringLength = 5 val naChance = 0.05 //5% of values will be NA def randString(len: Int): String = alphanumeric.take(len).mkString val uniqueStrings = (0 until numUniqueStrings).map { i => randString(minStringLength + nextInt(maxStringLength - minStringLength)) } val randomStrings = (0 until numValues).map(i => uniqueStrings(nextInt(numUniqueStrings))) val filoBufferNoNA = VectorBuilder(randomStrings).toFiloBuffer val scNoNA = FiloVector[String](filoBufferNoNA) def shouldNA: Boolean = nextFloat < naChance val filoBufferNA = VectorBuilder.fromOptions( randomStrings.map(str => if (shouldNA) None else Some(str)) ).toFiloBuffer val scNA = FiloVector[String](filoBufferNA) @Benchmark @BenchmarkMode(Array(Mode.AverageTime)) @OutputTimeUnit(TimeUnit.MICROSECONDS) def rawStringLengthTotal(): Int = { var totalLen = 0 for { i <- 0 until numValues optimized } { totalLen += scNoNA(i).length } totalLen } // TODO: also a benchmark for the foreach/fold of a column with no NA's? @Benchmark @BenchmarkMode(Array(Mode.AverageTime)) @OutputTimeUnit(TimeUnit.MICROSECONDS) // Measures foreach and NA read speed def withNAlengthTotal(): Unit = { var totalLen = 0 scNA.foreach { str => totalLen += str.length } totalLen } }
Example 53
Source File: UTF8StringBenchmark.scala From filo with Apache License 2.0 | 5 votes |
package org.velvia.filo import org.openjdk.jmh.annotations.Benchmark import org.openjdk.jmh.annotations.BenchmarkMode import org.openjdk.jmh.annotations.{Mode, State, Scope} import org.openjdk.jmh.annotations.OutputTimeUnit import java.util.concurrent.TimeUnit @State(Scope.Thread) class UTF8StringBenchmark { val str = "xylophonemania" val str2 = "xylophonemaniac" val zcStr = ZeroCopyUTF8String(str) val zcStr2 = ZeroCopyUTF8String(str2) // According to @ktosopl, be sure to return some value if possible so that JVM won't // optimize out the method body. However JMH is apparently very good at avoiding this. // fastest loop possible using FiloVectorApply method @Benchmark @BenchmarkMode(Array(Mode.Throughput)) @OutputTimeUnit(TimeUnit.SECONDS) def utf8StrCompare(): Int = { zcStr.compare(zcStr2) } @Benchmark @BenchmarkMode(Array(Mode.Throughput)) @OutputTimeUnit(TimeUnit.SECONDS) def nativeStrCompare(): Int = { str.compare(str2) } @Benchmark @BenchmarkMode(Array(Mode.Throughput)) @OutputTimeUnit(TimeUnit.SECONDS) def utf8Substring(): ZeroCopyUTF8String = { zcStr.substring(2, 6) } @Benchmark @BenchmarkMode(Array(Mode.Throughput)) @OutputTimeUnit(TimeUnit.SECONDS) def nativeSubstring(): String = { str.substring(2, 6) } @Benchmark @BenchmarkMode(Array(Mode.Throughput)) @OutputTimeUnit(TimeUnit.SECONDS) def utf8hash(): Int = { zcStr.hashCode } }
Example 54
Source File: BasicFiloBenchmark.scala From filo with Apache License 2.0 | 5 votes |
package org.velvia.filo import org.openjdk.jmh.annotations.Benchmark import org.openjdk.jmh.annotations.BenchmarkMode import org.openjdk.jmh.annotations.{Mode, State, Scope} import org.openjdk.jmh.annotations.OutputTimeUnit import scalaxy.loops._ import scala.language.postfixOps import java.util.concurrent.TimeUnit @State(Scope.Thread) class BasicFiloBenchmark { import VectorReader._ import vectors.IntBinaryVector // Ok, create an IntColumn and benchmark it. val numValues = 10000 val randomInts = (0 until numValues).map(i => util.Random.nextInt) val randomIntsAray = randomInts.toArray val filoBuffer = VectorBuilder(randomInts).toFiloBuffer val sc = FiloVector[Int](filoBuffer) val ivbuilder = IntBinaryVector.appendingVectorNoNA(numValues) randomInts.foreach(ivbuilder.addData) val iv = IntBinaryVector(ivbuilder.base, ivbuilder.offset, ivbuilder.numBytes) val byteFiloBuf = VectorBuilder(randomInts.map(_ % 128)).toFiloBuffer val byteVect = FiloVector[Int](byteFiloBuf) val diffFiloBuf = VectorBuilder(randomInts.map(10000 + _ % 128)).toFiloBuffer val diffVect = FiloVector[Int](diffFiloBuf) // According to @ktosopl, be sure to return some value if possible so that JVM won't // optimize out the method body. However JMH is apparently very good at avoiding this. // fastest loop possible using FiloVectorApply method @Benchmark @BenchmarkMode(Array(Mode.AverageTime)) @OutputTimeUnit(TimeUnit.MICROSECONDS) def sumAllIntsFiloApply(): Int = { var total = 0 for { i <- 0 until numValues optimized } { total += sc(i) } total } @Benchmark @BenchmarkMode(Array(Mode.AverageTime)) @OutputTimeUnit(TimeUnit.MICROSECONDS) def sumAllIntsBinaryVectApply(): Int = { var total = 0 for { i <- 0 until numValues optimized } { total += iv(i) } total } @Benchmark @BenchmarkMode(Array(Mode.AverageTime)) @OutputTimeUnit(TimeUnit.MICROSECONDS) def sumAllIntsFiloByteApply(): Int = { var total = 0 for { i <- 0 until numValues optimized } { total += byteVect(i) } total } @Benchmark @BenchmarkMode(Array(Mode.AverageTime)) @OutputTimeUnit(TimeUnit.MICROSECONDS) def sumAllIntsFiloDiffApply(): Int = { var total = 0 for { i <- 0 until numValues optimized } { total += diffVect(i) } total } @Benchmark @BenchmarkMode(Array(Mode.AverageTime)) @OutputTimeUnit(TimeUnit.MICROSECONDS) def sumAllNotNullIntsFiloApply(): Int = { var total = 0 for { i <- 0 until numValues optimized } { if (sc.isAvailable(i)) total += sc(i) } total } // sum which uses foreach from FiloVector @Benchmark @BenchmarkMode(Array(Mode.AverageTime)) @OutputTimeUnit(TimeUnit.MICROSECONDS) def sumAllIntsFiloForeachFoldLeft(): Int = { sc.foldLeft(0)(_ + _) } }
Example 55
Source File: FastFiloRowReaderBenchmark.scala From filo with Apache License 2.0 | 5 votes |
package org.velvia.filo import java.sql.Timestamp import org.openjdk.jmh.annotations.Benchmark import org.openjdk.jmh.annotations.BenchmarkMode import org.openjdk.jmh.annotations.{Mode, State, Scope} import org.openjdk.jmh.annotations.OutputTimeUnit import scalaxy.loops._ import scala.language.postfixOps import java.util.concurrent.TimeUnit @State(Scope.Thread) class FastFiloRowReaderBenchmark { import VectorReader._ // Ok, create an IntColumn and benchmark it. val numValues = 10000 val randomInts = (0 until numValues).map(i => util.Random.nextInt) val randomLongs = randomInts.map(_.toLong) val randomTs = randomLongs.map(l => new Timestamp(l)) val chunks = Array(VectorBuilder(randomInts).toFiloBuffer, VectorBuilder(randomLongs).toFiloBuffer, VectorBuilder(randomTs).toFiloBuffer) val clazzes = Array[Class[_]](classOf[Int], classOf[Long], classOf[Timestamp]) // According to @ktosopl, be sure to return some value if possible so that JVM won't // optimize out the method body. However JMH is apparently very good at avoiding this. // fastest loop possible using FiloVectorApply method @Benchmark @BenchmarkMode(Array(Mode.AverageTime)) @OutputTimeUnit(TimeUnit.MICROSECONDS) def createFastFiloRowReader(): RowReader = { new FastFiloRowReader(chunks, clazzes) } val fastReader = new FastFiloRowReader(chunks, clazzes) @Benchmark @BenchmarkMode(Array(Mode.Throughput)) @OutputTimeUnit(TimeUnit.SECONDS) def fastFiloRowReaderReadOne(): Int = { fastReader.setRowNo(0) if (fastReader.notNull(0)) fastReader.getInt(0) + 1 else 0 } }
Example 56
Source File: MutableBitSetReading.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.PlayJsonFormats._ import com.github.plokhotnyuk.jsoniter_scala.core._ import io.circe.parser._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import scala.collection.mutable class MutableBitSetReading extends MutableBitSetBenchmark { @Benchmark def avSystemGenCodec(): mutable.BitSet = JsonStringInput.read[mutable.BitSet](new String(jsonBytes, UTF_8)) @Benchmark def circe(): mutable.BitSet = decode[mutable.BitSet](new String(jsonBytes, UTF_8)).fold(throw _, identity) @Benchmark def jsoniterScala(): mutable.BitSet = readFromArray[mutable.BitSet](jsonBytes) @Benchmark def playJson(): mutable.BitSet = Json.parse(jsonBytes).as[mutable.BitSet] }
Example 57
Source File: ArrayOfFloatsWriting.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ //import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.core._ //import com.jsoniter.output.JsoniterJavaSerializer import com.rallyhealth.weejson.v1.jackson.ToJson import com.rallyhealth.weepickle.v1.WeePickle.FromScala //import io.circe.parser._ import io.circe.syntax._ import org.openjdk.jmh.annotations.Benchmark //import play.api.libs.json.Json //import spray.json._ class ArrayOfFloatsWriting extends ArrayOfFloatsBenchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringOutput.write(obj).getBytes(UTF_8) @Benchmark def borer(): Array[Byte] = io.bullet.borer.Json.encode(obj).toByteArray @Benchmark def circe(): Array[Byte] = printer.print(obj.asJson).getBytes(UTF_8) @Benchmark def dslJsonScala(): Array[Byte] = dslJsonEncode(obj) @Benchmark def jacksonScala(): Array[Byte] = jacksonMapper.writeValueAsBytes(obj) @Benchmark def uPickle(): Array[Byte] = write(obj).getBytes(UTF_8) @Benchmark def weePickle(): Array[Byte] = FromScala(obj).transform(ToJson.bytes) }
Example 58
Source File: ArrayOfLocalDatesWriting.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.ToJson import com.rallyhealth.weepickle.v1.WeePickle.FromScala import io.circe.syntax._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ class ArrayOfLocalDatesWriting extends ArrayOfLocalDatesBenchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringOutput.write(obj).getBytes(UTF_8) @Benchmark def borer(): Array[Byte] = io.bullet.borer.Json.encode(obj).toByteArray @Benchmark def circe(): Array[Byte] = printer.print(obj.asJson).getBytes(UTF_8) @Benchmark def dslJsonScala(): Array[Byte] = dslJsonEncode(obj) @Benchmark def jacksonScala(): Array[Byte] = jacksonMapper.writeValueAsBytes(obj) @Benchmark def jsoniterScala(): Array[Byte] = writeToArray(obj) @Benchmark def jsoniterScalaPrealloc(): Int = writeToSubArray(obj, preallocatedBuf, 0, preallocatedBuf.length) @Benchmark def playJson(): Array[Byte] = Json.toBytes(Json.toJson(obj)) @Benchmark def sprayJson(): Array[Byte] = obj.toJson.compactPrint.getBytes(UTF_8) @Benchmark def uPickle(): Array[Byte] = write(obj).getBytes(UTF_8) @Benchmark def weePickle(): Array[Byte] = FromScala(obj).transform(ToJson.bytes) }
Example 59
Source File: Base64Writing.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json.JsonStringOutput import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.core.{writeToArray, writeToSubArray} import com.rallyhealth.weejson.v1.jackson.ToJson import com.rallyhealth.weepickle.v1.WeePickle.FromScala import org.openjdk.jmh.annotations.Benchmark import io.circe.syntax._ class Base64Writing extends Base64Benchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringOutput.write(obj, jsonBase64Options).getBytes(UTF_8) @Benchmark def borer(): Array[Byte] = io.bullet.borer.Json.encode(obj).toByteArray @Benchmark def circe(): Array[Byte] = printer.print(obj.asJson(base64E5r)).getBytes(UTF_8) @Benchmark def dslJsonScala(): Array[Byte] = dslJsonEncode(obj) @Benchmark def jacksonScala(): Array[Byte] = jacksonMapper.writeValueAsBytes(obj) @Benchmark def jsoniterScala(): Array[Byte] = writeToArray(obj)(base64Codec) @Benchmark def jsoniterScalaPrealloc(): Int = writeToSubArray(obj, preallocatedBuf, 0, preallocatedBuf.length)(base64Codec) @Benchmark def weePickle(): Array[Byte] = FromScala(obj).transform(ToJson.bytes) }
Example 60
Source File: ArrayOfIntsReading.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.FromJson import com.rallyhealth.weepickle.v1.WeePickle.ToScala import io.circe.parser._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ import upickle.default._ class ArrayOfIntsReading extends ArrayOfIntsBenchmark { @Benchmark def avSystemGenCodec(): Array[Int] = JsonStringInput.read[Array[Int]](new String(jsonBytes, UTF_8)) @Benchmark def borer(): Array[Int] = io.bullet.borer.Json.decode(jsonBytes).to[Array[Int]].value @Benchmark def circe(): Array[Int] = decode[Array[Int]](new String(jsonBytes, UTF_8)).fold(throw _, identity) @Benchmark def dslJsonScala(): Array[Int] = dslJsonDecode[Array[Int]](jsonBytes) @Benchmark def jacksonScala(): Array[Int] = jacksonMapper.readValue[Array[Int]](jsonBytes) @Benchmark def jsoniterScala(): Array[Int] = readFromArray[Array[Int]](jsonBytes) @Benchmark def playJson(): Array[Int] = Json.parse(jsonBytes).as[Array[Int]] @Benchmark def sprayJson(): Array[Int] = JsonParser(jsonBytes).convertTo[Array[Int]] @Benchmark def uPickle(): Array[Int] = read[Array[Int]](jsonBytes) @Benchmark def weePickle(): Array[Int] = FromJson(jsonBytes).transform(ToScala[Array[Int]]) }
Example 61
Source File: ArrayOfLocalDatesReading.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import java.time.LocalDate import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.FromJson import com.rallyhealth.weepickle.v1.WeePickle.ToScala import io.circe.parser._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ class ArrayOfLocalDatesReading extends ArrayOfLocalDatesBenchmark { @Benchmark def avSystemGenCodec(): Array[LocalDate] = JsonStringInput.read[Array[LocalDate]](new String(jsonBytes, UTF_8)) @Benchmark def borer(): Array[LocalDate] = io.bullet.borer.Json.decode(jsonBytes).to[Array[LocalDate]].value @Benchmark def circe(): Array[LocalDate] = decode[Array[LocalDate]](new String(jsonBytes, UTF_8)).fold(throw _, identity) @Benchmark def dslJsonScala(): Array[LocalDate] = dslJsonDecode[Array[LocalDate]](jsonBytes) @Benchmark def jacksonScala(): Array[LocalDate] = jacksonMapper.readValue[Array[LocalDate]](jsonBytes) @Benchmark def jsoniterScala(): Array[LocalDate] = readFromArray[Array[LocalDate]](jsonBytes) @Benchmark def playJson(): Array[LocalDate] = Json.parse(jsonBytes).as[Array[LocalDate]] @Benchmark def sprayJson(): Array[LocalDate] = JsonParser(jsonBytes).convertTo[Array[LocalDate]] @Benchmark def uPickle(): Array[LocalDate] = read[Array[LocalDate]](jsonBytes) @Benchmark def weePickle(): Array[LocalDate] = FromJson(jsonBytes).transform(ToScala[Array[LocalDate]]) }
Example 62
Source File: ArrayOfZonedDateTimesWriting.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ //import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.ToJson import com.rallyhealth.weepickle.v1.WeePickle.FromScala import io.circe.syntax._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ class ArrayOfZonedDateTimesWriting extends ArrayOfZonedDateTimesBenchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringOutput.write(obj).getBytes(UTF_8) @Benchmark def borer(): Array[Byte] = io.bullet.borer.Json.encode(obj).toByteArray @Benchmark def circe(): Array[Byte] = printer.print(obj.asJson).getBytes(UTF_8) @Benchmark def jacksonScala(): Array[Byte] = jacksonMapper.writeValueAsBytes(obj) @Benchmark def jsoniterScala(): Array[Byte] = writeToArray(obj) @Benchmark def jsoniterScalaPrealloc(): Int = writeToSubArray(obj, preallocatedBuf, 0, preallocatedBuf.length) @Benchmark def playJson(): Array[Byte] = Json.toBytes(Json.toJson(obj)) @Benchmark def sprayJson(): Array[Byte] = obj.toJson.compactPrint.getBytes(UTF_8) @Benchmark def uPickle(): Array[Byte] = write(obj).getBytes(UTF_8) @Benchmark def weePickle(): Array[Byte] = FromScala(obj).transform(ToJson.bytes) }
Example 63
Source File: MutableMapOfIntsToBooleansWriting.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.PlayJsonFormats._ import com.github.plokhotnyuk.jsoniter_scala.core._ import io.circe.syntax._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json class MutableMapOfIntsToBooleansWriting extends MutableMapOfIntsToBooleansBenchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringOutput.write(obj).getBytes(UTF_8) @Benchmark def circe(): Array[Byte] = printer.print(obj.asJson).getBytes(UTF_8) @Benchmark def dslJsonScala(): Array[Byte] = dslJsonEncode(obj) @Benchmark def jacksonScala(): Array[Byte] = jacksonMapper.writeValueAsBytes(obj) @Benchmark def jsoniterScala(): Array[Byte] = writeToArray(obj) @Benchmark def jsoniterScalaPrealloc(): Int = writeToSubArray(obj, preallocatedBuf, 0, preallocatedBuf.length) @Benchmark def playJson(): Array[Byte] = Json.toBytes(Json.toJson(obj)) }
Example 64
Source File: StringOfEscapedCharsWriting.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.WeePickleFromTos._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weepickle.v1.WeePickle.FromScala import io.circe.syntax._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import upickle.default._ class StringOfEscapedCharsWriting extends StringOfEscapedCharsBenchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringOutput.write(obj, JsonOptions(asciiOutput = true)).getBytes(UTF_8) @Benchmark def circe(): Array[Byte] = escapingPrinter.print(obj.asJson).getBytes @Benchmark def jacksonScala(): Array[Byte] = jacksonEscapeNonAsciiMapper.writeValueAsBytes(obj) @Benchmark def jsoniterScala(): Array[Byte] = writeToArray(obj, escapingConfig)(stringCodec) @Benchmark def jsoniterScalaPrealloc(): Int = writeToSubArray(obj, preallocatedBuf, 0, preallocatedBuf.length, escapingConfig)(stringCodec) @Benchmark def playJson(): Array[Byte] = Json.asciiStringify(Json.toJson(obj)).getBytes @Benchmark def uPickle(): Array[Byte] = write(obj, escapeUnicode = true).getBytes(UTF_8) @Benchmark def weePickle(): Array[Byte] = FromScala(obj).transform(ToEscapedNonAsciiJson.bytes) }
Example 65
Source File: AnyValsWriting.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.FlatSprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.PlayJsonFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.WeePickleFromTos._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.ToJson import com.rallyhealth.weepickle.v1.WeePickle.FromScala import io.circe.syntax._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ class AnyValsWriting extends AnyValsBenchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringOutput.write(obj).getBytes(UTF_8) @Benchmark def borer(): Array[Byte] = io.bullet.borer.Json.encode(obj).toByteArray @Benchmark def circe(): Array[Byte] = printer.print(obj.asJson).getBytes(UTF_8) @Benchmark def jacksonScala(): Array[Byte] = jacksonMapper.writeValueAsBytes(obj) @Benchmark def jsoniterScala(): Array[Byte] = writeToArray(obj) @Benchmark def jsoniterScalaPrealloc(): Int = writeToSubArray(obj, preallocatedBuf, 0, preallocatedBuf.length) @Benchmark def playJson(): Array[Byte] = Json.toBytes(Json.toJson(obj)) @Benchmark def sprayJson(): Array[Byte] = obj.toJson.compactPrint.getBytes(UTF_8) @Benchmark def uPickle(): Array[Byte] = write(obj).getBytes(UTF_8) @Benchmark def weePickle(): Array[Byte] = FromScala(obj).transform(ToJson.bytes) }
Example 66
Source File: BitSetReading.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.PlayJsonFormats._ import com.github.plokhotnyuk.jsoniter_scala.core._ import io.circe.parser._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import scala.collection.immutable.BitSet class BitSetReading extends BitSetBenchmark { @Benchmark def avSystemGenCodec(): BitSet = JsonStringInput.read[BitSet](new String(jsonBytes, UTF_8)) @Benchmark def circe(): BitSet = decode[BitSet](new String(jsonBytes, UTF_8)).fold(throw _, identity) @Benchmark def jsoniterScala(): BitSet = readFromArray[BitSet](jsonBytes) @Benchmark def playJson(): BitSet = Json.parse(jsonBytes).as[BitSet](bitSetFormat) }
Example 67
Source File: MutableMapOfIntsToBooleansReading.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.PlayJsonFormats._ import com.github.plokhotnyuk.jsoniter_scala.core._ import io.circe.parser._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import scala.collection.mutable class MutableMapOfIntsToBooleansReading extends MutableMapOfIntsToBooleansBenchmark { @Benchmark def avSystemGenCodec(): mutable.Map[Int, Boolean] = JsonStringInput.read[mutable.Map[Int, Boolean]](new String(jsonBytes, UTF_8)) @Benchmark def circe(): mutable.Map[Int, Boolean] = decode[mutable.Map[Int, Boolean]](new String(jsonBytes, UTF_8)).fold(throw _, identity) @Benchmark def dslJsonScala(): mutable.Map[Int, Boolean] = dslJsonDecode[mutable.Map[Int, Boolean]](jsonBytes) @Benchmark def jacksonScala(): mutable.Map[Int, Boolean] = jacksonMapper.readValue[mutable.Map[Int, Boolean]](jsonBytes) @Benchmark def jsoniterScala(): mutable.Map[Int, Boolean] = readFromArray[mutable.Map[Int, Boolean]](jsonBytes) @Benchmark def playJson(): mutable.Map[Int, Boolean] = Json.parse(jsonBytes).as[mutable.Map[Int, Boolean]] }
Example 68
Source File: ArrayOfFloatsReading.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.core._ //import com.rallyhealth.weejson.v1.jackson.FromJson //import com.rallyhealth.weepickle.v1.WeePickle.ToScala import io.circe.parser._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ class ArrayOfFloatsReading extends ArrayOfFloatsBenchmark { @Benchmark def avSystemGenCodec(): Array[Float] = JsonStringInput.read[Array[Float]](new String(jsonBytes, UTF_8)) @Benchmark def borer(): Array[Float] = io.bullet.borer.Json.decode(jsonBytes).withConfig(decodingConfig).to[Array[Float]].value @Benchmark def circe(): Array[Float] = decode[Array[Float]](new String(jsonBytes, UTF_8)).fold(throw _, identity) }
Example 69
Source File: ArrayOfBigDecimalsWriting.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.core._ //import com.rallyhealth.weejson.v1.jackson.ToJson //import com.rallyhealth.weepickle.v1.WeePickle.FromScala import io.circe.syntax._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ class ArrayOfBigDecimalsWriting extends ArrayOfBigDecimalsBenchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringOutput.write(obj).getBytes(UTF_8) @Benchmark def borer(): Array[Byte] = io.bullet.borer.Json.encode(obj).toByteArray @Benchmark def circe(): Array[Byte] = printer.print(obj.asJson).getBytes(UTF_8) @Benchmark def dslJsonScala(): Array[Byte] = dslJsonEncode(obj) @Benchmark def jacksonScala(): Array[Byte] = jacksonMapper.writeValueAsBytes(obj) @Benchmark def jsoniterScala(): Array[Byte] = writeToArray(obj) @Benchmark def jsoniterScalaPrealloc(): Int = writeToSubArray(obj, preallocatedBuf, 0, preallocatedBuf.length) @Benchmark def playJson(): Array[Byte] = Json.toBytes(Json.toJson(obj)) @Benchmark def sprayJson(): Array[Byte] = obj.toJson.compactPrint.getBytes(UTF_8) @Benchmark def uPickle(): Array[Byte] = write(obj).getBytes(UTF_8) }
Example 70
Source File: ListOfBooleansReading.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.FromJson import com.rallyhealth.weepickle.v1.WeePickle.ToScala import io.circe.parser._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ import upickle.default._ class ListOfBooleansReading extends ListOfBooleansBenchmark { @Benchmark def avSystemGenCodec(): List[Boolean] = JsonStringInput.read[List[Boolean]](new String(jsonBytes, UTF_8)) @Benchmark def borer(): List[Boolean] = io.bullet.borer.Json.decode(jsonBytes).to[List[Boolean]].value @Benchmark def circe(): List[Boolean] = decode[List[Boolean]](new String(jsonBytes, UTF_8)).fold(throw _, identity) @Benchmark def dslJsonScala(): List[Boolean] = dslJsonDecode[List[Boolean]](jsonBytes) @Benchmark def jacksonScala(): List[Boolean] = jacksonMapper.readValue[List[Boolean]](jsonBytes) @Benchmark def jsoniterScala(): List[Boolean] = readFromArray[List[Boolean]](jsonBytes) @Benchmark def playJson(): List[Boolean] = Json.parse(jsonBytes).as[List[Boolean]] @Benchmark def sprayJson(): List[Boolean] = JsonParser(jsonBytes).convertTo[List[Boolean]] @Benchmark def uPickle(): List[Boolean] = read[List[Boolean]](jsonBytes) @Benchmark def weePickle(): List[Boolean] = FromJson(jsonBytes).transform(ToScala[List[Boolean]]) }
Example 71
Source File: ArrayBufferOfBooleansReading.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.FromJson import com.rallyhealth.weepickle.v1.WeePickle.ToScala import io.circe.parser._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ import upickle.default._ import scala.collection.mutable class ArrayBufferOfBooleansReading extends ArrayBufferOfBooleansBenchmark { @Benchmark def avSystemGenCodec(): mutable.ArrayBuffer[Boolean] = JsonStringInput.read[mutable.ArrayBuffer[Boolean]](new String(jsonBytes, UTF_8)) @Benchmark def borer(): mutable.ArrayBuffer[Boolean] = io.bullet.borer.Json.decode(jsonBytes).to[mutable.ArrayBuffer[Boolean]].value @Benchmark def circe(): mutable.ArrayBuffer[Boolean] = decode[mutable.ArrayBuffer[Boolean]](new String(jsonBytes, UTF_8)).fold(throw _, identity) @Benchmark def dslJsonScala(): mutable.ArrayBuffer[Boolean] = dslJsonDecode[mutable.ArrayBuffer[Boolean]](jsonBytes) @Benchmark def jacksonScala(): mutable.ArrayBuffer[Boolean] = jacksonMapper.readValue[mutable.ArrayBuffer[Boolean]](jsonBytes) @Benchmark def jsoniterScala(): mutable.ArrayBuffer[Boolean] = readFromArray[mutable.ArrayBuffer[Boolean]](jsonBytes) @Benchmark def playJson(): mutable.ArrayBuffer[Boolean] = Json.parse(jsonBytes).as[mutable.ArrayBuffer[Boolean]] @Benchmark def sprayJson(): mutable.ArrayBuffer[Boolean] = JsonParser(jsonBytes).convertTo[mutable.ArrayBuffer[Boolean]] @Benchmark def uPickle(): mutable.ArrayBuffer[Boolean] = read[mutable.ArrayBuffer[Boolean]](jsonBytes) @Benchmark def weePickle(): mutable.ArrayBuffer[Boolean] = FromJson(jsonBytes).transform(ToScala[mutable.ArrayBuffer[Boolean]]) }
Example 72
Source File: StringOfNonAsciiCharsReading.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.FromJson import com.rallyhealth.weepickle.v1.WeePickle.ToScala import io.circe.parser._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import upickle.default._ class StringOfNonAsciiCharsReading extends StringOfNonAsciiCharsBenchmark { @Benchmark def avSystemGenCodec(): String = JsonStringInput.read[String](new String(jsonBytes, UTF_8)) @Benchmark def borer(): String = io.bullet.borer.Json.decode(jsonBytes).to[String].value @Benchmark def circe(): String = decode[String](new String(jsonBytes, UTF_8)).fold(throw _, identity) @Benchmark def dslJsonScala(): String = dslJsonDecode[String](jsonBytes)(stringDecoder) @Benchmark def jacksonScala(): String = jacksonMapper.readValue[String](jsonBytes) @Benchmark def jsoniterScala(): String = readFromArray[String](jsonBytes, tooLongStringConfig)(stringCodec) @Benchmark def playJson(): String = Json.parse(jsonBytes).as[String] @Benchmark def sprayJson(): String = spray.json.JsonParser(jsonBytes).convertTo[String] @Benchmark def uPickle(): String = read[String](jsonBytes) @Benchmark def weePickle(): String = FromJson(jsonBytes).transform(ToScala[String]) }
Example 73
Source File: StringOfAsciiCharsWriting.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.ToJson import com.rallyhealth.weepickle.v1.WeePickle.FromScala import io.circe.syntax._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import upickle.default._ class StringOfAsciiCharsWriting extends StringOfAsciiCharsBenchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringOutput.write(obj).getBytes(UTF_8) @Benchmark def borer(): Array[Byte] = io.bullet.borer.Json.encode(obj).toByteArray @Benchmark def circe(): Array[Byte] = printer.print(obj.asJson).getBytes(UTF_8) @Benchmark def dslJsonScala(): Array[Byte] = dslJsonEncode(obj)(stringEncoder) @Benchmark def jacksonScala(): Array[Byte] = jacksonMapper.writeValueAsBytes(obj) @Benchmark def jsoniterScala(): Array[Byte] = writeToArray(obj)(stringCodec) @Benchmark def jsoniterScalaPrealloc(): Int = writeToSubArray(obj, preallocatedBuf, 0, preallocatedBuf.length)(stringCodec) @Benchmark def playJson(): Array[Byte] = Json.toBytes(Json.toJson(obj)) @Benchmark def sprayJson(): Array[Byte] = { import spray.json._ obj.toJson.compactPrint.getBytes(UTF_8) } @Benchmark def uPickle(): Array[Byte] = write(obj).getBytes(UTF_8) @Benchmark def weePickle(): Array[Byte] = FromScala(obj).transform(ToJson.bytes) }
Example 74
Source File: ArrayOfJavaEnumsReading.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.PlayJsonFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.WeePickleFromTos._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.FromJson import com.rallyhealth.weepickle.v1.WeePickle.ToScala import io.circe.parser._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ class ArrayOfJavaEnumsReading extends ArrayOfJavaEnumsBenchmark { @Benchmark def avSystemGenCodec(): Array[Suit] = JsonStringInput.read[Array[Suit]](new String(jsonBytes, UTF_8)) @Benchmark def borer(): Array[Suit] = io.bullet.borer.Json.decode(jsonBytes).to[Array[Suit]].value @Benchmark def circe(): Array[Suit] = decode[Array[Suit]](new String(jsonBytes, UTF_8)).fold(throw _, identity) @Benchmark def dslJsonScala(): Array[Suit] = dslJsonDecode[Array[Suit]](jsonBytes) @Benchmark def jacksonScala(): Array[Suit] = jacksonMapper.readValue[Array[Suit]](jsonBytes) @Benchmark def jsoniterScala(): Array[Suit] = readFromArray[Array[Suit]](jsonBytes) @Benchmark def playJson(): Array[Suit] = Json.parse(jsonBytes).as[Array[Suit]] @Benchmark def sprayJson(): Array[Suit] = JsonParser(jsonBytes).convertTo[Array[Suit]] @Benchmark def uPickle(): Array[Suit] = read[Array[Suit]](jsonBytes) @Benchmark def weePickle(): Array[Suit] = FromJson(jsonBytes).transform(ToScala[Array[Suit]]) }
Example 75
Source File: MutableSetOfIntsReading.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.FromJson import com.rallyhealth.weepickle.v1.WeePickle.ToScala import io.circe.parser._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import upickle.default._ import scala.collection.mutable class MutableSetOfIntsReading extends MutableSetOfIntsBenchmark { @Benchmark def avSystemGenCodec(): mutable.Set[Int] = JsonStringInput.read[mutable.Set[Int]](new String(jsonBytes, UTF_8)) @Benchmark def borer(): mutable.Set[Int] = io.bullet.borer.Json.decode(jsonBytes).to[mutable.Set[Int]].value @Benchmark def circe(): mutable.Set[Int] = decode[mutable.Set[Int]](new String(jsonBytes, UTF_8)).fold(throw _, identity) @Benchmark def dslJsonScala(): mutable.Set[Int] = dslJsonDecode[mutable.Set[Int]](jsonBytes) @Benchmark def jacksonScala(): mutable.Set[Int] = jacksonMapper.readValue[mutable.Set[Int]](jsonBytes) @Benchmark def jsoniterScala(): mutable.Set[Int] = readFromArray[mutable.Set[Int]](jsonBytes) @Benchmark def playJson(): mutable.Set[Int] = Json.parse(jsonBytes).as[mutable.Set[Int]] @Benchmark def uPickle(): mutable.Set[Int] = read[mutable.Set[Int]](jsonBytes) @Benchmark def weePickle(): mutable.Set[Int] = FromJson(jsonBytes).transform(ToScala[mutable.Set[Int]]) }
Example 76
Source File: ArrayOfPeriodsWriting.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.core._ import io.circe.syntax._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ class ArrayOfPeriodsWriting extends ArrayOfPeriodsBenchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringOutput.write(obj).getBytes(UTF_8) @Benchmark def borer(): Array[Byte] = io.bullet.borer.Json.encode(obj).toByteArray @Benchmark def circe(): Array[Byte] = printer.print(obj.asJson).getBytes(UTF_8) @Benchmark def jacksonScala(): Array[Byte] = jacksonMapper.writeValueAsBytes(obj) @Benchmark def jsoniterScala(): Array[Byte] = writeToArray(obj) @Benchmark def jsoniterScalaPrealloc(): Int = writeToSubArray(obj, preallocatedBuf, 0, preallocatedBuf.length) @Benchmark def playJson(): Array[Byte] = Json.toBytes(Json.toJson(obj)) @Benchmark def sprayJson(): Array[Byte] = obj.toJson.compactPrint.getBytes(UTF_8) @Benchmark def uPickle(): Array[Byte] = write(obj).getBytes(UTF_8) }
Example 77
Source File: GoogleMapsAPIWriting.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.PlayJsonFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.WeePickleFromTos._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.ToJson import com.rallyhealth.weepickle.v1.WeePickle.FromScala import io.circe.syntax._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ class GoogleMapsAPIWriting extends GoogleMapsAPIBenchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringOutput.write(obj).getBytes(UTF_8) @Benchmark def borer(): Array[Byte] = io.bullet.borer.Json.encode(obj).toByteArray @Benchmark def circe(): Array[Byte] = printer.print(obj.asJson).getBytes(UTF_8) @Benchmark def dslJsonScala(): Array[Byte] = dslJsonEncode(obj) @Benchmark def jacksonScala(): Array[Byte] = jacksonMapper.writeValueAsBytes(obj) @Benchmark def jsoniterScala(): Array[Byte] = writeToArray(obj) @Benchmark def jsoniterScalaPrealloc(): Int = writeToSubArray(obj, preallocatedBuf, 0, preallocatedBuf.length) @Benchmark def playJson(): Array[Byte] = Json.toBytes(Json.toJson(obj)) @Benchmark def sprayJson(): Array[Byte] = obj.toJson.compactPrint.getBytes(UTF_8) @Benchmark def uPickle(): Array[Byte] = write(obj).getBytes(UTF_8) @Benchmark def weePickle(): Array[Byte] = FromScala(obj).transform(ToJson.bytes) }
Example 78
Source File: OpenRTBWriting.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json.JsonStringOutput import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ //import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ //import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ //import com.github.plokhotnyuk.jsoniter_scala.benchmark.PlayJsonFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.WeePickleFromTos._ //import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.ToJson import com.rallyhealth.weepickle.v1.WeePickle.FromScala //import io.circe.syntax._ import org.openjdk.jmh.annotations.Benchmark //import play.api.libs.json.Json //import spray.json._ class OpenRTBWriting extends OpenRTBBenchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringOutput.write(obj).getBytes(UTF_8) @Benchmark def borer(): Array[Byte] = io.bullet.borer.Json.encode(obj).toByteArray @Benchmark def uPickle(): Array[Byte] = write(obj).getBytes(UTF_8) @Benchmark def weePickle(): Array[Byte] = FromScala(obj).transform(ToJson.bytes) }
Example 79
Source File: BigDecimalWriting.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.core._ //import com.rallyhealth.weejson.v1.jackson.ToJson //import com.rallyhealth.weepickle.v1.WeePickle.FromScala import io.circe.syntax._ import org.openjdk.jmh.annotations.Benchmark import spray.json._ class BigDecimalWriting extends BigDecimalBenchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringOutput.write(obj).getBytes(UTF_8) @Benchmark def borer(): Array[Byte] = io.bullet.borer.Json.encode(obj).toByteArray @Benchmark def circe(): Array[Byte] = printer.print(obj.asJson).getBytes(UTF_8) @Benchmark def dslJsonScala(): Array[Byte] = dslJsonEncode(obj) @Benchmark def jacksonScala(): Array[Byte] = jacksonMapper.writeValueAsBytes(obj) @Benchmark def jsoniterScala(): Array[Byte] = writeToArray(obj)(bigDecimalCodec) @Benchmark def jsoniterScalaPrealloc(): Int = writeToSubArray(obj, preallocatedBuf, 0, preallocatedBuf.length)(bigDecimalCodec) }
Example 80
Source File: ArrayOfEnumsReading.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.PlayJsonFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.WeePickleFromTos._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SuitEnum.SuitEnum import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.FromJson import com.rallyhealth.weepickle.v1.WeePickle.ToScala import io.circe.parser._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ class ArrayOfEnumsReading extends ArrayOfEnumsBenchmark { @Benchmark def avSystemGenCodec(): Array[SuitEnum] = JsonStringInput.read[Array[SuitEnum]](new String(jsonBytes, UTF_8)) @Benchmark def borer(): Array[SuitEnum] = io.bullet.borer.Json.decode(jsonBytes).to[Array[SuitEnum]].value @Benchmark def circe(): Array[SuitEnum] = decode[Array[SuitEnum]](new String(jsonBytes, UTF_8)).fold(throw _, identity) @Benchmark def jacksonScala(): Array[SuitEnum] = jacksonMapper.readValue[Array[SuitEnum]](jsonBytes) @Benchmark def jsoniterScala(): Array[SuitEnum] = readFromArray[Array[SuitEnum]](jsonBytes) @Benchmark def playJson(): Array[SuitEnum] = Json.parse(jsonBytes).as[Array[SuitEnum]] @Benchmark def sprayJson(): Array[SuitEnum] = JsonParser(jsonBytes).convertTo[Array[SuitEnum]] @Benchmark def uPickle(): Array[SuitEnum] = read[Array[SuitEnum]](jsonBytes) @Benchmark def weePickle(): Array[SuitEnum] = FromJson(jsonBytes).transform(ToScala[Array[SuitEnum]]) }
Example 81
Source File: ArrayOfEnumADTsReading.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.PlayJsonFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.WeePickleFromTos._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.FromJson import com.rallyhealth.weepickle.v1.WeePickle.ToScala import io.circe.parser._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ class ArrayOfEnumADTsReading extends ArrayOfEnumADTsBenchmark { @Benchmark def avSystemGenCodec(): Array[SuitADT] = JsonStringInput.read[Array[SuitADT]](new String(jsonBytes, UTF_8)) @Benchmark def borer(): Array[SuitADT] = io.bullet.borer.Json.decode(jsonBytes).to[Array[SuitADT]].value @Benchmark def circe(): Array[SuitADT] = decode[Array[SuitADT]](new String(jsonBytes, UTF_8)).fold(throw _, identity) @Benchmark def dslJsonScala(): Array[SuitADT] = dslJsonDecode[Array[SuitADT]](jsonBytes) @Benchmark def jacksonScala(): Array[SuitADT] = jacksonMapper.readValue[Array[SuitADT]](jsonBytes) @Benchmark def jsoniterScala(): Array[SuitADT] = readFromArray[Array[SuitADT]](jsonBytes) @Benchmark def playJson(): Array[SuitADT] = Json.parse(jsonBytes).as[Array[SuitADT]] @Benchmark def sprayJson(): Array[SuitADT] = JsonParser(jsonBytes).convertTo[Array[SuitADT]] @Benchmark def uPickle(): Array[SuitADT] = read[Array[SuitADT]](jsonBytes) @Benchmark def weePickle(): Array[SuitADT] = FromJson(jsonBytes).transform(ToScala[Array[SuitADT]]) }
Example 82
Source File: SetOfIntsReading.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.FromJson import com.rallyhealth.weepickle.v1.WeePickle.ToScala import io.circe.parser._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ import upickle.default._ import scala.collection.immutable.Set class SetOfIntsReading extends SetOfIntsBenchmark { @Benchmark def avSystemGenCodec(): Set[Int] = JsonStringInput.read[Set[Int]](new String(jsonBytes, UTF_8)) @Benchmark def borer(): Set[Int] = io.bullet.borer.Json.decode(jsonBytes).to[Set[Int]].value @Benchmark def circe(): Set[Int] = decode[Set[Int]](new String(jsonBytes, UTF_8)).fold(throw _, identity) @Benchmark def dslJsonScala(): Set[Int] = dslJsonDecode[Set[Int]](jsonBytes) @Benchmark def jacksonScala(): Set[Int] = jacksonMapper.readValue[Set[Int]](jsonBytes) @Benchmark def jsoniterScala(): Set[Int] = readFromArray[Set[Int]](jsonBytes) @Benchmark def playJson(): Set[Int] = Json.parse(jsonBytes).as[Set[Int]] @Benchmark def sprayJson(): Set[Int] = JsonParser(jsonBytes).convertTo[Set[Int]] @Benchmark def uPickle(): Set[Int] = read[Set[Int]](jsonBytes) @Benchmark def weePickle(): Set[Int] = FromJson(jsonBytes).transform(ToScala[Set[Int]]) }
Example 83
Source File: TwitterAPIWriting.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.rallyhealth.weejson.v1.jackson.ToJson import com.rallyhealth.weepickle.v1.WeePickle.FromScala import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ //import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.WeePickleFromTos._ import com.github.plokhotnyuk.jsoniter_scala.core._ //import io.circe.syntax._ import org.openjdk.jmh.annotations.Benchmark //import spray.json._ class TwitterAPIWriting extends TwitterAPIBenchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringOutput.write(obj).getBytes(UTF_8) @Benchmark def borer(): Array[Byte] = io.bullet.borer.Json.encode(obj).toByteArray @Benchmark def uPickle(): Array[Byte] = write(obj).getBytes(UTF_8) @Benchmark def weePickle(): Array[Byte] = FromScala(obj).transform(ToJson.bytes) }
Example 84
Source File: NestedStructsWriting.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ //import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.PlayJsonFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.WeePickleFromTos._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.ToJson import com.rallyhealth.weepickle.v1.WeePickle.FromScala import io.circe.syntax._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ class NestedStructsWriting extends NestedStructsBenchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringOutput.write(obj).getBytes(UTF_8) @Benchmark def jacksonScala(): Array[Byte] = jacksonMapper.writeValueAsBytes(obj) @Benchmark def jsoniterScala(): Array[Byte] = writeToArray(obj) @Benchmark def jsoniterScalaPrealloc(): Int = writeToSubArray(obj, preallocatedBuf, 0, preallocatedBuf.length) @Benchmark def playJson(): Array[Byte] = Json.toBytes(Json.toJson(obj)) @Benchmark def sprayJson(): Array[Byte] = obj.toJson(nestedStructsJsonFormat).compactPrint.getBytes(UTF_8) @Benchmark def uPickle(): Array[Byte] = write(obj).getBytes(UTF_8) @Benchmark def weePickle(): Array[Byte] = FromScala(obj).transform(ToJson.bytes) }
Example 85
Source File: IntReading.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.FromJson import com.rallyhealth.weepickle.v1.WeePickle.ToScala import io.circe.parser._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ import upickle.default._ class IntReading extends IntBenchmark { @Benchmark def avSystemGenCodec(): Int = JsonStringInput.read[Int](new String(jsonBytes, UTF_8)) @Benchmark def borer(): Int = io.bullet.borer.Json.decode(jsonBytes).to[Int].value @Benchmark def circe(): Int = decode[Int](new String(jsonBytes, UTF_8)).fold(throw _, identity) @Benchmark def dslJsonScala(): Int = dslJsonDecode[Int](jsonBytes) @Benchmark def jacksonScala(): Int = jacksonMapper.readValue[Int](jsonBytes) @Benchmark def jsoniterScala(): Int = readFromArray[Int](jsonBytes)(intCodec) @Benchmark def playJson(): Int = Json.parse(jsonBytes).as[Int] @Benchmark def sprayJson(): Int = JsonParser(jsonBytes).convertTo[Int] @Benchmark def uPickle(): Int = read[Int](jsonBytes) @Benchmark def weePickle(): Int = FromJson(jsonBytes).transform(ToScala[Int]) }
Example 86
Source File: ADTWriting.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.PlayJsonFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.WeePickleFromTos._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.ToJson import com.rallyhealth.weepickle.v1.WeePickle.FromScala import io.circe.syntax._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ class ADTWriting extends ADTBenchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringOutput.write(obj).getBytes(UTF_8) @Benchmark def borer(): Array[Byte] = io.bullet.borer.Json.encode(obj).toByteArray @Benchmark def circe(): Array[Byte] = printer.print(obj.asJson).getBytes(UTF_8) @Benchmark def jacksonScala(): Array[Byte] = jacksonMapper.writeValueAsBytes(obj) @Benchmark def jsoniterScala(): Array[Byte] = writeToArray(obj) @Benchmark def jsoniterScalaPrealloc(): Int = writeToSubArray(obj, preallocatedBuf, 0, preallocatedBuf.length) @Benchmark def playJson(): Array[Byte] = Json.toBytes(Json.toJson(obj)(adtFormat)) @Benchmark def sprayJson(): Array[Byte] = obj.toJson(adtBaseJsonFormat).compactPrint.getBytes(UTF_8) @Benchmark def uPickle(): Array[Byte] = write(obj).getBytes(UTF_8) @Benchmark def weePickle(): Array[Byte] = FromScala(obj).transform(ToJson.bytes) }
Example 87
Source File: ArrayOfUUIDsReading.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import java.util.UUID import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.FromJson import com.rallyhealth.weepickle.v1.WeePickle.ToScala import io.circe.parser._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ import upickle.default._ class ArrayOfUUIDsReading extends ArrayOfUUIDsBenchmark { @Benchmark def avSystemGenCodec(): Array[UUID] = JsonStringInput.read[Array[UUID]](new String(jsonBytes, UTF_8)) @Benchmark def borer(): Array[UUID] = io.bullet.borer.Json.decode(jsonBytes).to[Array[UUID]].value @Benchmark def circe(): Array[UUID] = decode[Array[UUID]](new String(jsonBytes, UTF_8)).fold(throw _, identity) @Benchmark def dslJsonScala(): Array[UUID] = dslJsonDecode[Array[UUID]](jsonBytes) @Benchmark def jacksonScala(): Array[UUID] = jacksonMapper.readValue[Array[UUID]](jsonBytes) @Benchmark def jsoniterScala(): Array[UUID] = readFromArray[Array[UUID]](jsonBytes) @Benchmark def playJson(): Array[UUID] = Json.parse(jsonBytes).as[Array[UUID]] @Benchmark def sprayJson(): Array[UUID] = JsonParser(jsonBytes).convertTo[Array[UUID]] @Benchmark def uPickle(): Array[UUID] = read[Array[UUID]](jsonBytes) @Benchmark def weePickle(): Array[UUID] = FromJson(jsonBytes).transform(ToScala[Array[UUID]]) }
Example 88
Source File: ArrayOfZoneIdsReading.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import java.time.ZoneId import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.core._ import io.circe.parser._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ class ArrayOfZoneIdsReading extends ArrayOfZoneIdsBenchmark { @Benchmark def avSystemGenCodec(): Array[ZoneId] = JsonStringInput.read[Array[ZoneId]](new String(jsonBytes, UTF_8)) @Benchmark def borer(): Array[ZoneId] = io.bullet.borer.Json.decode(jsonBytes).to[Array[ZoneId]].value @Benchmark def circe(): Array[ZoneId] = decode[Array[ZoneId]](new String(jsonBytes, UTF_8)).fold(throw _, identity) @Benchmark def jacksonScala(): Array[ZoneId] = jacksonMapper.readValue[Array[ZoneId]](jsonBytes) @Benchmark def jsoniterScala(): Array[ZoneId] = readFromArray[Array[ZoneId]](jsonBytes) @Benchmark def playJson(): Array[ZoneId] = Json.parse(jsonBytes).as[Array[ZoneId]] @Benchmark def sprayJson(): Array[ZoneId] = JsonParser(jsonBytes).convertTo[Array[ZoneId]] @Benchmark def uPickle(): Array[ZoneId] = read[Array[ZoneId]](jsonBytes) }
Example 89
Source File: ArrayOfZonedDateTimesReading.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import java.time.ZonedDateTime import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ //import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.FromJson import com.rallyhealth.weepickle.v1.WeePickle.ToScala import io.circe.parser._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ class ArrayOfZonedDateTimesReading extends ArrayOfZonedDateTimesBenchmark { @Benchmark def avSystemGenCodec(): Array[ZonedDateTime] = JsonStringInput.read[Array[ZonedDateTime]](new String(jsonBytes, UTF_8)) @Benchmark def borer(): Array[ZonedDateTime] = io.bullet.borer.Json.decode(jsonBytes).to[Array[ZonedDateTime]].value @Benchmark def circe(): Array[ZonedDateTime] = decode[Array[ZonedDateTime]](new String(jsonBytes, UTF_8)).fold(throw _, identity) @Benchmark def jacksonScala(): Array[ZonedDateTime] = jacksonMapper.readValue[Array[ZonedDateTime]](jsonBytes) @Benchmark def jsoniterScala(): Array[ZonedDateTime] = readFromArray[Array[ZonedDateTime]](jsonBytes) @Benchmark def playJson(): Array[ZonedDateTime] = Json.parse(jsonBytes).as[Array[ZonedDateTime]] @Benchmark def sprayJson(): Array[ZonedDateTime] = JsonParser(jsonBytes).convertTo[Array[ZonedDateTime]] @Benchmark def uPickle(): Array[ZonedDateTime] = read[Array[ZonedDateTime]](jsonBytes) @Benchmark def weePickle(): Array[ZonedDateTime] = FromJson(jsonBytes).transform(ToScala[Array[ZonedDateTime]]) }
Example 90
Source File: ArrayOfMonthDaysReading.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import java.time.MonthDay import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.PlayJsonFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.core._ import io.circe.parser._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ class ArrayOfMonthDaysReading extends ArrayOfMonthDaysBenchmark { @Benchmark def avSystemGenCodec(): Array[MonthDay] = JsonStringInput.read[Array[MonthDay]](new String(jsonBytes, UTF_8)) @Benchmark def borer(): Array[MonthDay] = io.bullet.borer.Json.decode(jsonBytes).to[Array[MonthDay]].value @Benchmark def circe(): Array[MonthDay] = decode[Array[MonthDay]](new String(jsonBytes, UTF_8)).fold(throw _, identity) @Benchmark def jacksonScala(): Array[MonthDay] = jacksonMapper.readValue[Array[MonthDay]](jsonBytes) @Benchmark def jsoniterScala(): Array[MonthDay] = readFromArray[Array[MonthDay]](jsonBytes) @Benchmark def playJson(): Array[MonthDay] = Json.parse(jsonBytes).as[Array[MonthDay]] @Benchmark def uPickle(): Array[MonthDay] = read[Array[MonthDay]](jsonBytes) @Benchmark def sprayJson(): Array[MonthDay] = JsonParser(jsonBytes).convertTo[Array[MonthDay]] }
Example 91
Source File: ArrayOfOffsetTimesWriting.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.PlayJsonFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.core._ import io.circe.syntax._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ class ArrayOfOffsetTimesWriting extends ArrayOfOffsetTimesBenchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringOutput.write(obj).getBytes(UTF_8) @Benchmark def borer(): Array[Byte] = io.bullet.borer.Json.encode(obj).toByteArray @Benchmark def circe(): Array[Byte] = printer.print(obj.asJson).getBytes(UTF_8) @Benchmark def dslJsonScala(): Array[Byte] = dslJsonEncode(obj) @Benchmark def jacksonScala(): Array[Byte] = jacksonMapper.writeValueAsBytes(obj) @Benchmark def jsoniterScala(): Array[Byte] = writeToArray(obj) @Benchmark def jsoniterScalaPrealloc(): Int = writeToSubArray(obj, preallocatedBuf, 0, preallocatedBuf.length) @Benchmark def playJson(): Array[Byte] = Json.toBytes(Json.toJson(obj)) @Benchmark def sprayJson(): Array[Byte] = obj.toJson.compactPrint.getBytes(UTF_8) @Benchmark def uPickle(): Array[Byte] = write(obj).getBytes(UTF_8) }
Example 92
Source File: TwitterAPIReading.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.PlayJsonFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.TwitterAPI._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.WeePickleFromTos._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.FromJson import com.rallyhealth.weepickle.v1.WeePickle.ToScala import io.circe.parser._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ import scala.collection.immutable.Seq class TwitterAPIReading extends TwitterAPIBenchmark { @Benchmark def avSystemGenCodec(): Seq[Tweet] = JsonStringInput.read[Seq[Tweet]](new String(jsonBytes, UTF_8)) @Benchmark def borer(): Seq[Tweet] = io.bullet.borer.Json.decode(jsonBytes).to[Seq[Tweet]].value @Benchmark def circe(): Seq[Tweet] = decode[Seq[Tweet]](new String(jsonBytes, UTF_8)).fold(throw _, identity) @Benchmark def dslJsonScala(): Seq[Tweet] = dslJsonDecode[Seq[Tweet]](jsonBytes) @Benchmark def jacksonScala(): Seq[Tweet] = jacksonMapper.readValue[Seq[Tweet]](jsonBytes) @Benchmark def jsoniterScala(): Seq[Tweet] = readFromArray[Seq[Tweet]](jsonBytes) @Benchmark def playJson(): Seq[Tweet] = Json.parse(jsonBytes).as[Seq[Tweet]] @Benchmark def sprayJson(): Seq[Tweet] = JsonParser(jsonBytes).convertTo[Seq[Tweet]] @Benchmark def uPickle(): Seq[Tweet] = read[Seq[Tweet]](jsonBytes) @Benchmark def weePickle(): Seq[Tweet] = FromJson(jsonBytes).transform(ToScala[Seq[Tweet]]) }
Example 93
Source File: MutableLongMapOfBooleansReading.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ //import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ //import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.PlayJsonFormats._ import com.github.plokhotnyuk.jsoniter_scala.core._ import io.circe.parser._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import scala.collection.mutable class MutableLongMapOfBooleansReading extends MutableLongMapOfBooleansBenchmark { @Benchmark def avSystemGenCodec(): mutable.LongMap[Boolean] = JsonStringInput.read[mutable.LongMap[Boolean]](new String(jsonBytes, UTF_8)) @Benchmark def circe(): mutable.LongMap[Boolean] = decode[mutable.LongMap[Boolean]](new String(jsonBytes, UTF_8)).fold(throw _, identity) @Benchmark def jsoniterScala(): mutable.LongMap[Boolean] = readFromArray[mutable.LongMap[Boolean]](jsonBytes) @Benchmark def playJson(): mutable.LongMap[Boolean] = Json.parse(jsonBytes).as[mutable.LongMap[Boolean]] }
Example 94
Source File: ArrayOfZoneOffsetsWriting.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.PlayJsonFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.core._ import io.circe.syntax._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ class ArrayOfZoneOffsetsWriting extends ArrayOfZoneOffsetsBenchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringOutput.write(obj).getBytes(UTF_8) @Benchmark def borer(): Array[Byte] = io.bullet.borer.Json.encode(obj).toByteArray @Benchmark def circe(): Array[Byte] = printer.print(obj.asJson).getBytes(UTF_8) @Benchmark def jacksonScala(): Array[Byte] = jacksonMapper.writeValueAsBytes(obj) @Benchmark def jsoniterScala(): Array[Byte] = writeToArray(obj) @Benchmark def jsoniterScalaPrealloc(): Int = writeToSubArray(obj, preallocatedBuf, 0, preallocatedBuf.length) @Benchmark def playJson(): Array[Byte] = Json.toBytes(Json.toJson(obj)) @Benchmark def sprayJson(): Array[Byte] = obj.toJson.compactPrint.getBytes(UTF_8) @Benchmark def uPickle(): Array[Byte] = write(obj).getBytes(UTF_8) }
Example 95
Source File: ArrayOfEnumsWriting.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.PlayJsonFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.WeePickleFromTos._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.ToJson import com.rallyhealth.weepickle.v1.WeePickle.FromScala import io.circe.syntax._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ class ArrayOfEnumsWriting extends ArrayOfEnumsBenchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringOutput.write(obj).getBytes(UTF_8) @Benchmark def borer(): Array[Byte] = io.bullet.borer.Json.encode(obj).toByteArray @Benchmark def circe(): Array[Byte] = printer.print(obj.asJson).getBytes(UTF_8) @Benchmark def jacksonScala(): Array[Byte] = jacksonMapper.writeValueAsBytes(obj) @Benchmark def jsoniterScala(): Array[Byte] = writeToArray(obj) @Benchmark def jsoniterScalaPrealloc(): Int = writeToSubArray(obj, preallocatedBuf, 0, preallocatedBuf.length) @Benchmark def playJson(): Array[Byte] = Json.toBytes(Json.toJson(obj)) @Benchmark def sprayJson(): Array[Byte] = obj.toJson.compactPrint.getBytes(UTF_8) @Benchmark def uPickle(): Array[Byte] = write(obj).getBytes(UTF_8) @Benchmark def weePickle(): Array[Byte] = FromScala(obj).transform(ToJson.bytes) }
Example 96
Source File: BigIntWriting.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.core._ //import com.rallyhealth.weejson.v1.jackson.ToJson //import com.rallyhealth.weepickle.v1.WeePickle.FromScala import io.circe.syntax._ import org.openjdk.jmh.annotations.Benchmark //import play.api.libs.json.Json import spray.json._ class BigIntWriting extends BigIntBenchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringOutput.write(obj).getBytes(UTF_8) @Benchmark def borer(): Array[Byte] = io.bullet.borer.Json.encode(obj).toByteArray @Benchmark def circe(): Array[Byte] = printer.print(obj.asJson).getBytes(UTF_8) @Benchmark def dslJsonScala(): Array[Byte] = dslJsonEncode(obj)(bigIntgEncoder) @Benchmark def jacksonScala(): Array[Byte] = jacksonMapper.writeValueAsBytes(obj) @Benchmark def jsoniterScala(): Array[Byte] = writeToArray(obj)(bigIntCodec) @Benchmark def jsoniterScalaPrealloc(): Int = writeToSubArray(obj, preallocatedBuf, 0, preallocatedBuf.length)(bigIntCodec) }
Example 97
Source File: StringOfEscapedCharsReading.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.FromJson import com.rallyhealth.weepickle.v1.WeePickle.ToScala import io.circe.parser._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import upickle.default._ class StringOfEscapedCharsReading extends StringOfEscapedCharsBenchmark { @Benchmark def avSystemGenCodec(): String = JsonStringInput.read[String](new String(jsonBytes, UTF_8)) @Benchmark def borer(): String = io.bullet.borer.Json.decode(jsonBytes).to[String].value @Benchmark def circe(): String = decode[String](new String(jsonBytes, UTF_8)).fold(throw _, identity) @Benchmark def dslJsonScala(): String = dslJsonDecode[String](jsonBytes)(stringDecoder) @Benchmark def jacksonScala(): String = jacksonEscapeNonAsciiMapper.readValue[String](jsonBytes) @Benchmark def jsoniterScala(): String = readFromArray[String](jsonBytes, tooLongStringConfig)(stringCodec) @Benchmark def playJson(): String = Json.parse(jsonBytes).as[String] @Benchmark def sprayJson(): String = spray.json.JsonParser(jsonBytes).convertTo[String] @Benchmark def uPickle(): String = read[String](jsonBytes) @Benchmark def weePickle(): String = FromJson(jsonBytes).transform(ToScala[String]) }
Example 98
Source File: GitHubActionsAPIReading.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.WeePickleFromTos._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.FromJson import com.rallyhealth.weepickle.v1.WeePickle.ToScala import io.circe.parser.decode import org.openjdk.jmh.annotations.Benchmark import spray.json.JsonParser class GitHubActionsAPIReading extends GitHubActionsAPIBenchmark { @Benchmark def avSystemGenCodec(): GitHubActionsAPI.Response = JsonStringInput.read[GitHubActionsAPI.Response](new String(jsonBytes, UTF_8)) @Benchmark def borer(): GitHubActionsAPI.Response = io.bullet.borer.Json.decode(jsonBytes).to[GitHubActionsAPI.Response].value @Benchmark def circe(): GitHubActionsAPI.Response = decode[GitHubActionsAPI.Response](new String(jsonBytes, UTF_8)).fold(throw _, identity) @Benchmark def jacksonScala(): GitHubActionsAPI.Response = jacksonMapper.readValue[GitHubActionsAPI.Response](jsonBytes) @Benchmark def jsoniterScala(): GitHubActionsAPI.Response = readFromArray[GitHubActionsAPI.Response](jsonBytes) @Benchmark def sprayJson(): GitHubActionsAPI.Response = JsonParser(jsonBytes).convertTo[GitHubActionsAPI.Response] @Benchmark def weePickle(): GitHubActionsAPI.Response = FromJson(jsonBytes).transform(ToScala[GitHubActionsAPI.Response]) }
Example 99
Source File: GoogleMapsAPIReading.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.GoogleMapsAPI._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.PlayJsonFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.WeePickleFromTos._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.FromJson import com.rallyhealth.weepickle.v1.WeePickle.ToScala import io.circe.parser._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ class GoogleMapsAPIReading extends GoogleMapsAPIBenchmark { @Benchmark def avSystemGenCodec(): DistanceMatrix = JsonStringInput.read[DistanceMatrix](new String(jsonBytes1, UTF_8)) @Benchmark def borer(): DistanceMatrix = io.bullet.borer.Json.decode(jsonBytes1).to[DistanceMatrix].value @Benchmark def circe(): DistanceMatrix = decode[DistanceMatrix](new String(jsonBytes1, UTF_8)).fold(throw _, identity) @Benchmark def dslJsonScala(): DistanceMatrix = dslJsonDecode[DistanceMatrix](jsonBytes1) @Benchmark def jacksonScala(): DistanceMatrix = jacksonMapper.readValue[DistanceMatrix](jsonBytes1) @Benchmark def jsoniterScala(): DistanceMatrix = readFromArray[DistanceMatrix](jsonBytes1) @Benchmark def playJson(): DistanceMatrix = Json.parse(jsonBytes1).as[DistanceMatrix] @Benchmark def sprayJson(): DistanceMatrix = JsonParser(jsonBytes1).convertTo[DistanceMatrix] @Benchmark def uPickle(): DistanceMatrix = read[DistanceMatrix](jsonBytes1) @Benchmark def weePickle(): DistanceMatrix = FromJson(jsonBytes1).transform(ToScala[DistanceMatrix]) }
Example 100
Source File: VectorOfBooleansWriting.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.ToJson import com.rallyhealth.weepickle.v1.WeePickle.FromScala import io.circe.syntax._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ import upickle.default._ class VectorOfBooleansWriting extends VectorOfBooleansBenchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringOutput.write(obj).getBytes(UTF_8) @Benchmark def borer(): Array[Byte] = io.bullet.borer.Json.encode(obj).toByteArray @Benchmark def circe(): Array[Byte] = printer.print(obj.asJson).getBytes(UTF_8) @Benchmark def dslJsonScala(): Array[Byte] = dslJsonEncode(obj) @Benchmark def jacksonScala(): Array[Byte] = jacksonMapper.writeValueAsBytes(obj) @Benchmark def jsoniterScala(): Array[Byte] = writeToArray(obj) @Benchmark def jsoniterScalaPrealloc(): Int = writeToSubArray(obj, preallocatedBuf, 0, preallocatedBuf.length) @Benchmark def playJson(): Array[Byte] = Json.toBytes(Json.toJson(obj)) @Benchmark def sprayJson(): Array[Byte] = obj.toJson.compactPrint.getBytes(UTF_8) @Benchmark def uPickle(): Array[Byte] = write(obj).getBytes(UTF_8) @Benchmark def weePickle(): Array[Byte] = FromScala(obj).transform(ToJson.bytes) }
Example 101
Source File: ArrayOfEnumADTsWriting.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.PlayJsonFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.WeePickleFromTos._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.ToJson import com.rallyhealth.weepickle.v1.WeePickle.FromScala import io.circe.syntax._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ class ArrayOfEnumADTsWriting extends ArrayOfEnumADTsBenchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringOutput.write(obj).getBytes(UTF_8) @Benchmark def borer(): Array[Byte] = io.bullet.borer.Json.encode(obj).toByteArray @Benchmark def circe(): Array[Byte] = printer.print(obj.asJson).getBytes(UTF_8) @Benchmark def dslJsonScala(): Array[Byte] = dslJsonEncode(obj) @Benchmark def jacksonScala(): Array[Byte] = jacksonMapper.writeValueAsBytes(obj) @Benchmark def jsoniterScala(): Array[Byte] = writeToArray(obj) @Benchmark def jsoniterScalaPrealloc(): Int = writeToSubArray(obj, preallocatedBuf, 0, preallocatedBuf.length) @Benchmark def playJson(): Array[Byte] = Json.toBytes(Json.toJson(obj)) @Benchmark def sprayJson(): Array[Byte] = obj.toJson.compactPrint.getBytes(UTF_8) @Benchmark def uPickle(): Array[Byte] = write(obj).getBytes(UTF_8) @Benchmark def weePickle(): Array[Byte] = FromScala(obj).transform(ToJson.bytes) }
Example 102
Source File: ArrayOfYearMonthsWriting.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.PlayJsonFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.core._ import io.circe.syntax._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ class ArrayOfYearMonthsWriting extends ArrayOfYearMonthsBenchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringOutput.write(obj).getBytes(UTF_8) @Benchmark def borer(): Array[Byte] = io.bullet.borer.Json.encode(obj).toByteArray @Benchmark def circe(): Array[Byte] = printer.print(obj.asJson).getBytes(UTF_8) @Benchmark def jacksonScala(): Array[Byte] = jacksonMapper.writeValueAsBytes(obj) @Benchmark def jsoniterScala(): Array[Byte] = writeToArray(obj) @Benchmark def jsoniterScalaPrealloc(): Int = writeToSubArray(obj, preallocatedBuf, 0, preallocatedBuf.length) @Benchmark def playJson(): Array[Byte] = Json.toBytes(Json.toJson(obj)) @Benchmark def sprayJson(): Array[Byte] = obj.toJson.compactPrint.getBytes(UTF_8) @Benchmark def uPickle(): Array[Byte] = write(obj).getBytes(UTF_8) }
Example 103
Source File: ArrayOfBooleansWriting.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.ToJson import com.rallyhealth.weepickle.v1.WeePickle.FromScala import io.circe.syntax._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ import upickle.default._ class ArrayOfBooleansWriting extends ArrayOfBooleansBenchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringOutput.write(obj).getBytes(UTF_8) @Benchmark def borer(): Array[Byte] = io.bullet.borer.Json.encode(obj).toByteArray @Benchmark def circe(): Array[Byte] = printer.print(obj.asJson).getBytes(UTF_8) @Benchmark def dslJsonScala(): Array[Byte] = dslJsonEncode(obj) @Benchmark def jacksonScala(): Array[Byte] = jacksonMapper.writeValueAsBytes(obj) @Benchmark def jsoniterScala(): Array[Byte] = writeToArray(obj) @Benchmark def jsoniterScalaPrealloc(): Int = writeToSubArray(obj, preallocatedBuf, 0, preallocatedBuf.length) @Benchmark def playJson(): Array[Byte] = Json.toBytes(Json.toJson(obj)) @Benchmark def sprayJson(): Array[Byte] = obj.toJson.compactPrint.getBytes(UTF_8) @Benchmark def uPickle(): Array[Byte] = write(obj).getBytes(UTF_8) @Benchmark def weePickle(): Array[Byte] = FromScala(obj).transform(ToJson.bytes) }
Example 104
Source File: GitHubActionsAPIWriting.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json.JsonStringOutput import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.WeePickleFromTos._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.ToJson import com.rallyhealth.weepickle.v1.WeePickle.FromScala import io.circe.syntax._ import org.openjdk.jmh.annotations.Benchmark import spray.json._ class GitHubActionsAPIWriting extends GitHubActionsAPIBenchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringOutput.write(obj).getBytes(UTF_8) @Benchmark def borer(): Array[Byte] = io.bullet.borer.Json.encode(obj).toByteArray @Benchmark def circe(): Array[Byte] = printer.print(obj.asJson).getBytes(UTF_8) @Benchmark def jacksonScala(): Array[Byte] = jacksonMapper.writeValueAsBytes(obj) @Benchmark def jsoniterScala(): Array[Byte] = writeToArray(obj) @Benchmark def jsoniterScalaPrealloc(): Int = writeToSubArray(obj, preallocatedBuf, 0, preallocatedBuf.length) @Benchmark def sprayJson(): Array[Byte] = obj.toJson.compactPrint.getBytes(UTF_8) @Benchmark def weePickle(): Array[Byte] = FromScala(obj).transform(ToJson.bytes) }
Example 105
Source File: ArrayOfUUIDsWriting.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.ToJson import com.rallyhealth.weepickle.v1.WeePickle.FromScala import io.circe.syntax._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ import upickle.default._ class ArrayOfUUIDsWriting extends ArrayOfUUIDsBenchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringOutput.write(obj).getBytes(UTF_8) @Benchmark def borer(): Array[Byte] = io.bullet.borer.Json.encode(obj).toByteArray @Benchmark def circe(): Array[Byte] = printer.print(obj.asJson).getBytes(UTF_8) @Benchmark def dslJsonScala(): Array[Byte] = dslJsonEncode(obj) @Benchmark def jacksonScala(): Array[Byte] = jacksonMapper.writeValueAsBytes(obj) @Benchmark def jsoniterScala(): Array[Byte] = writeToArray(obj) @Benchmark def jsoniterScalaPrealloc(): Int = writeToSubArray(obj, preallocatedBuf, 0, preallocatedBuf.length) @Benchmark def playJson(): Array[Byte] = Json.toBytes(Json.toJson(obj)) @Benchmark def sprayJson(): Array[Byte] = obj.toJson.compactPrint.getBytes(UTF_8) @Benchmark def uPickle(): Array[Byte] = write(obj).getBytes(UTF_8) @Benchmark def weePickle(): Array[Byte] = FromScala(obj).transform(ToJson.bytes) }
Example 106
Source File: ArrayOfDoublesWriting.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.ToJson import com.rallyhealth.weepickle.v1.WeePickle.FromScala import io.circe.syntax._ import org.openjdk.jmh.annotations.Benchmark //import play.api.libs.json.Json //import spray.json._ class ArrayOfDoublesWriting extends ArrayOfDoublesBenchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringOutput.write(obj).getBytes(UTF_8) @Benchmark def borer(): Array[Byte] = io.bullet.borer.Json.encode(obj).toByteArray @Benchmark def circe(): Array[Byte] = printer.print(obj.asJson).getBytes(UTF_8) @Benchmark def uPickle(): Array[Byte] = write(obj).getBytes(UTF_8) @Benchmark def weePickle(): Array[Byte] = FromScala(obj).transform(ToJson.bytes) }
Example 107
Source File: ArrayOfLocalTimesReading.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import java.time.LocalTime import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.FromJson import com.rallyhealth.weepickle.v1.WeePickle.ToScala import io.circe.parser._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ class ArrayOfLocalTimesReading extends ArrayOfLocalTimesBenchmark { @Benchmark def avSystemGenCodec(): Array[LocalTime] = JsonStringInput.read[Array[LocalTime]](new String(jsonBytes, UTF_8)) @Benchmark def borer(): Array[LocalTime] = io.bullet.borer.Json.decode(jsonBytes).to[Array[LocalTime]].value @Benchmark def circe(): Array[LocalTime] = decode[Array[LocalTime]](new String(jsonBytes, UTF_8)).fold(throw _, identity) @Benchmark def dslJsonScala(): Array[LocalTime] = dslJsonDecode[Array[LocalTime]](jsonBytes) @Benchmark def jacksonScala(): Array[LocalTime] = jacksonMapper.readValue[Array[LocalTime]](jsonBytes) @Benchmark def jsoniterScala(): Array[LocalTime] = readFromArray[Array[LocalTime]](jsonBytes) @Benchmark def playJson(): Array[LocalTime] = Json.parse(jsonBytes).as[Array[LocalTime]] @Benchmark def sprayJson(): Array[LocalTime] = JsonParser(jsonBytes).convertTo[Array[LocalTime]] @Benchmark def uPickle(): Array[LocalTime] = read[Array[LocalTime]](jsonBytes) @Benchmark def weePickle(): Array[LocalTime] = FromJson(jsonBytes).transform(ToScala[Array[LocalTime]]) }
Example 108
Source File: OpenRTBReading.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json.JsonStringInput import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.OpenRTB.BidRequest //import com.github.plokhotnyuk.jsoniter_scala.benchmark.PlayJsonFormats._ //import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.WeePickleFromTos._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.FromJson import com.rallyhealth.weepickle.v1.WeePickle.ToScala //import play.api.libs.json.Json //import spray.json.JsonParser import io.circe.parser._ import org.openjdk.jmh.annotations.Benchmark class OpenRTBReading extends OpenRTBBenchmark { @Benchmark def avSystemGenCodec(): BidRequest = JsonStringInput.read[BidRequest](new String(jsonBytes, UTF_8)) @Benchmark def borer(): BidRequest = io.bullet.borer.Json.decode(jsonBytes).to[BidRequest].value @Benchmark def circe(): BidRequest = decode[BidRequest](new String(jsonBytes, UTF_8)).fold(throw _, identity) @Benchmark def jacksonScala(): BidRequest = jacksonMapper.readValue[BidRequest](jsonBytes) @Benchmark def jsoniterScala(): BidRequest = readFromArray[BidRequest](jsonBytes) @Benchmark def uPickle(): BidRequest = read[BidRequest](jsonBytes) @Benchmark def weePickle(): BidRequest = FromJson(jsonBytes).transform(ToScala[BidRequest]) }
Example 109
Source File: ArrayOfOffsetDateTimesReading.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import java.time.OffsetDateTime import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.FromJson import com.rallyhealth.weepickle.v1.WeePickle.ToScala import io.circe.parser._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ class ArrayOfOffsetDateTimesReading extends ArrayOfOffsetDateTimesBenchmark { @Benchmark def avSystemGenCodec(): Array[OffsetDateTime] = JsonStringInput.read[Array[OffsetDateTime]](new String(jsonBytes, UTF_8)) @Benchmark def borer(): Array[OffsetDateTime] = io.bullet.borer.Json.decode(jsonBytes).to[Array[OffsetDateTime]].value @Benchmark def circe(): Array[OffsetDateTime] = decode[Array[OffsetDateTime]](new String(jsonBytes, UTF_8)).fold(throw _, identity) @Benchmark def dslJsonScala(): Array[OffsetDateTime] = dslJsonDecode[Array[OffsetDateTime]](jsonBytes) @Benchmark def jacksonScala(): Array[OffsetDateTime] = jacksonMapper.readValue[Array[OffsetDateTime]](jsonBytes) @Benchmark def jsoniterScala(): Array[OffsetDateTime] = readFromArray[Array[OffsetDateTime]](jsonBytes) @Benchmark def playJson(): Array[OffsetDateTime] = Json.parse(jsonBytes).as[Array[OffsetDateTime]] @Benchmark def sprayJson(): Array[OffsetDateTime] = JsonParser(jsonBytes).convertTo[Array[OffsetDateTime]] @Benchmark def uPickle(): Array[OffsetDateTime] = read[Array[OffsetDateTime]](jsonBytes) @Benchmark def weePickle(): Array[OffsetDateTime] = FromJson(jsonBytes).transform(ToScala[Array[OffsetDateTime]]) }
Example 110
Source File: ArrayOfPeriodsReading.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import java.time.Period import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.core._ import io.circe.parser._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ class ArrayOfPeriodsReading extends ArrayOfPeriodsBenchmark { @Benchmark def avSystemGenCodec(): Array[Period] = JsonStringInput.read[Array[Period]](new String(jsonBytes, UTF_8)) @Benchmark def borer(): Array[Period] = io.bullet.borer.Json.decode(jsonBytes).to[Array[Period]].value @Benchmark def circe(): Array[Period] = decode[Array[Period]](new String(jsonBytes, UTF_8)).fold(throw _, identity) @Benchmark def jacksonScala(): Array[Period] = jacksonMapper.readValue[Array[Period]](jsonBytes) @Benchmark def jsoniterScala(): Array[Period] = readFromArray[Array[Period]](jsonBytes) @Benchmark def playJson(): Array[Period] = Json.parse(jsonBytes).as[Array[Period]] @Benchmark def sprayJson(): Array[Period] = JsonParser(jsonBytes).convertTo[Array[Period]] @Benchmark def uPickle(): Array[Period] = read[Array[Period]](jsonBytes) }
Example 111
Source File: BigIntReading.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.FromJson import com.rallyhealth.weepickle.v1.WeePickle.ToScala import io.circe.parser._ import org.openjdk.jmh.annotations.Benchmark //import play.api.libs.json.Json import spray.json._ class BigIntReading extends BigIntBenchmark { @Benchmark def avSystemGenCodec(): BigInt = JsonStringInput.read[BigInt](new String(jsonBytes, UTF_8)) @Benchmark def borer(): BigInt = io.bullet.borer.Json.decode(jsonBytes).withConfig(decodingConfig).to[BigInt].value @Benchmark def circe(): BigInt = decode[BigInt](new String(jsonBytes, UTF_8)).fold(throw _, identity) @Benchmark def dslJsonScala(): BigInt = dslJsonDecode[BigInt](jsonBytes) @Benchmark def jacksonScala(): BigInt = jacksonMapper.readValue[BigInt](jsonBytes) @Benchmark def jsoniterScala(): BigInt = readFromArray[BigInt](jsonBytes)(bigIntCodec) @Benchmark def sprayJson(): BigInt = JsonParser(jsonBytes, jsonParserSettings).convertTo[BigInt] @Benchmark def uPickle(): BigInt = read[BigInt](jsonBytes) @Benchmark def weePickle(): BigInt = FromJson(jsonBytes).transform(ToScala[BigInt]) }
Example 112
Source File: ArrayOfLocalTimesWriting.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.ToJson import com.rallyhealth.weepickle.v1.WeePickle.FromScala import io.circe.syntax._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ class ArrayOfLocalTimesWriting extends ArrayOfLocalTimesBenchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringOutput.write(obj).getBytes(UTF_8) @Benchmark def borer(): Array[Byte] = io.bullet.borer.Json.encode(obj).toByteArray @Benchmark def circe(): Array[Byte] = printer.print(obj.asJson).getBytes(UTF_8) @Benchmark def dslJsonScala(): Array[Byte] = dslJsonEncode(obj) @Benchmark def jacksonScala(): Array[Byte] = jacksonMapper.writeValueAsBytes(obj) @Benchmark def jsoniterScala(): Array[Byte] = writeToArray(obj) @Benchmark def jsoniterScalaPrealloc(): Int = writeToSubArray(obj, preallocatedBuf, 0, preallocatedBuf.length) @Benchmark def playJson(): Array[Byte] = Json.toBytes(Json.toJson(obj)) @Benchmark def sprayJson(): Array[Byte] = obj.toJson.compactPrint.getBytes(UTF_8) @Benchmark def uPickle(): Array[Byte] = write(obj).getBytes(UTF_8) @Benchmark def weePickle(): Array[Byte] = FromScala(obj).transform(ToJson.bytes) }
Example 113
Source File: ExtractFieldsReading.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ //import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.HashCodeCollider._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.PlayJsonFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.WeePickleFromTos._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.FromJson import com.rallyhealth.weepickle.v1.WeePickle.ToScala import io.circe.parser._ import org.openjdk.jmh.annotations.{Benchmark, Param, Setup} import play.api.libs.json.Json import spray.json._ class ExtractFieldsReading extends CommonParams { @Param(Array("1", "10", "100", "1000", "10000", "100000", "1000000")) var size: Int = 1000 var obj: ExtractFields = ExtractFields("s", 1) var jsonString: String = _ var jsonBytes: Array[Byte] = _ @Setup def setup(): Unit = { val value = """{"number":0.0,"boolean":false,"string":null}""" jsonString = zeroHashCodeStrings.map(s => writeToString(s)(JsoniterScalaCodecs.stringCodec)).take(size) .mkString("""{"s":"s",""", s""":$value,""", s""":$value,"i":1}""") jsonBytes = jsonString.getBytes(UTF_8) } @Benchmark def avSystemGenCodec(): ExtractFields = JsonStringInput.read[ExtractFields](new String(jsonBytes, UTF_8)) @Benchmark def borer(): ExtractFields = io.bullet.borer.Json.decode(jsonBytes).to[ExtractFields].value @Benchmark def circe(): ExtractFields = decode[ExtractFields](new String(jsonBytes, UTF_8)).fold(throw _, identity) @Benchmark def jacksonScala(): ExtractFields = jacksonMapper.readValue[ExtractFields](jsonBytes) @Benchmark def jsoniterScala(): ExtractFields = readFromArray[ExtractFields](jsonBytes) @Benchmark def playJson(): ExtractFields = Json.parse(jsonBytes).as[ExtractFields] @Benchmark def sprayJson(): ExtractFields = JsonParser(jsonBytes).convertTo[ExtractFields] @Benchmark def uPickle(): ExtractFields = read[ExtractFields](jsonBytes) @Benchmark def weePickle(): ExtractFields = FromJson(jsonBytes).transform(ToScala[ExtractFields]) }
Example 114
Source File: ArrayOfInstantsWriting.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.ToJson import com.rallyhealth.weepickle.v1.WeePickle.FromScala import io.circe.syntax._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ class ArrayOfInstantsWriting extends ArrayOfInstantsBenchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringOutput.write(obj).getBytes(UTF_8) @Benchmark def borer(): Array[Byte] = io.bullet.borer.Json.encode(obj).toByteArray @Benchmark def circe(): Array[Byte] = printer.print(obj.asJson).getBytes(UTF_8) @Benchmark def jacksonScala(): Array[Byte] = jacksonMapper.writeValueAsBytes(obj) @Benchmark def jsoniterScala(): Array[Byte] = writeToArray(obj) @Benchmark def jsoniterScalaPrealloc(): Int = writeToSubArray(obj, preallocatedBuf, 0, preallocatedBuf.length) @Benchmark def playJson(): Array[Byte] = Json.toBytes(Json.toJson(obj)) @Benchmark def sprayJson(): Array[Byte] = obj.toJson.compactPrint.getBytes(UTF_8) @Benchmark def uPickle(): Array[Byte] = write(obj).getBytes(UTF_8) @Benchmark def weePickle(): Array[Byte] = FromScala(obj).transform(ToJson.bytes) }
Example 115
Source File: GoogleMapsAPIPrettyPrinting.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.PlayJsonFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.WeePickleFromTos._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weepickle.v1.WeePickle.FromScala import io.circe.syntax._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ class GoogleMapsAPIPrettyPrinting extends GoogleMapsAPIBenchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringOutput.write(obj, JsonOptions.Pretty).getBytes(UTF_8) @Benchmark def circe(): Array[Byte] = prettyPrinter.print(obj.asJson).getBytes(UTF_8) @Benchmark def jacksonScala(): Array[Byte] = jacksonPrettyMapper.writeValueAsBytes(obj) @Benchmark def jsoniterScala(): Array[Byte] = writeToArray(obj, prettyConfig) @Benchmark def jsoniterScalaPrealloc(): Int = writeToSubArray(obj, preallocatedBuf, 0, preallocatedBuf.length, prettyConfig) @Benchmark def playJson(): Array[Byte] = prettyPrintBytes(Json.toJson(obj)) @Benchmark def sprayJson(): Array[Byte] = CustomPrettyPrinter(obj.toJson).getBytes(UTF_8) @Benchmark def uPickle(): Array[Byte] = write(obj, 2).getBytes(UTF_8) @Benchmark def weePickle(): Array[Byte] = FromScala(obj).transform(ToPrettyJson.bytes) }
Example 116
Source File: ArrayOfInstantsReading.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import java.time.Instant import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.FromJson import com.rallyhealth.weepickle.v1.WeePickle.ToScala import io.circe.parser._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ class ArrayOfInstantsReading extends ArrayOfInstantsBenchmark { @Benchmark def avSystemGenCodec(): Array[Instant] = JsonStringInput.read[Array[Instant]](new String(jsonBytes, UTF_8)) @Benchmark def borer(): Array[Instant] = io.bullet.borer.Json.decode(jsonBytes).to[Array[Instant]].value @Benchmark def circe(): Array[Instant] = decode[Array[Instant]](new String(jsonBytes, UTF_8)).fold(throw _, identity) @Benchmark def jacksonScala(): Array[Instant] = jacksonMapper.readValue[Array[Instant]](jsonBytes) @Benchmark def jsoniterScala(): Array[Instant] = readFromArray[Array[Instant]](jsonBytes) @Benchmark def playJson(): Array[Instant] = Json.parse(jsonBytes).as[Array[Instant]] @Benchmark def sprayJson(): Array[Instant] = JsonParser(jsonBytes).convertTo[Array[Instant]] @Benchmark def uPickle(): Array[Instant] = read[Array[Instant]](jsonBytes) @Benchmark def weePickle(): Array[Instant] = FromJson(jsonBytes).transform(ToScala[Array[Instant]]) }
Example 117
Source File: MutableLongMapOfBooleansWriting.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ //import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.PlayJsonFormats._ import com.github.plokhotnyuk.jsoniter_scala.core._ import io.circe.syntax._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json class MutableLongMapOfBooleansWriting extends MutableLongMapOfBooleansBenchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringOutput.write(obj).getBytes(UTF_8) @Benchmark def circe(): Array[Byte] = printer.print(obj.asJson).getBytes(UTF_8) @Benchmark def jacksonScala(): Array[Byte] = jacksonMapper.writeValueAsBytes(obj) @Benchmark def jsoniterScala(): Array[Byte] = writeToArray(obj) @Benchmark def jsoniterScalaPrealloc(): Int = writeToSubArray(obj, preallocatedBuf, 0, preallocatedBuf.length) @Benchmark def playJson(): Array[Byte] = Json.toBytes(Json.toJson(obj)) }
Example 118
Source File: IntWriting.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.ToJson import com.rallyhealth.weepickle.v1.WeePickle.FromScala import io.circe.syntax._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import upickle.default._ class IntWriting extends IntBenchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringOutput.write(obj).getBytes(UTF_8) @Benchmark def borer(): Array[Byte] = io.bullet.borer.Json.encode(obj).toByteArray @Benchmark def circe(): Array[Byte] = printer.print(obj.asJson).getBytes(UTF_8) @Benchmark def dslJsonScala(): Array[Byte] = dslJsonEncode(obj) @Benchmark def jacksonScala(): Array[Byte] = jacksonMapper.writeValueAsBytes(obj) @Benchmark def jsoniterScala(): Array[Byte] = writeToArray(obj)(intCodec) @Benchmark def jsoniterScalaPrealloc(): Int = writeToSubArray(obj, preallocatedBuf, 0, preallocatedBuf.length)(intCodec) @Benchmark def playJson(): Array[Byte] = Json.toBytes(Json.toJson(obj)) @Benchmark def sprayJson(): Array[Byte] = Json.toBytes(Json.toJson(obj)) @Benchmark def uPickle(): Array[Byte] = write(obj).getBytes(UTF_8) @Benchmark def weePickle(): Array[Byte] = FromScala(obj).transform(ToJson.bytes) }
Example 119
Source File: GeoJSONReading.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.GeoJSON._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.PlayJsonFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.WeePickleFromTos._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.FromJson import com.rallyhealth.weepickle.v1.WeePickle.ToScala import io.circe.parser._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ class GeoJSONReading extends GeoJSONBenchmark { @Benchmark def avSystemGenCodec(): GeoJSON = JsonStringInput.read[GeoJSON](new String(jsonBytes, UTF_8)) @Benchmark def borer(): GeoJSON = io.bullet.borer.Json.decode(jsonBytes).to[GeoJSON].value @Benchmark def circe(): GeoJSON = decode[GeoJSON](new String(jsonBytes, UTF_8)).fold(throw _, identity) @Benchmark def jacksonScala(): GeoJSON = jacksonMapper.readValue[GeoJSON](jsonBytes) @Benchmark def jsoniterScala(): GeoJSON = readFromArray[GeoJSON](jsonBytes) @Benchmark def playJson(): GeoJSON = Json.parse(jsonBytes).as[GeoJSON](geoJSONFormat) @Benchmark def sprayJson(): GeoJSON = JsonParser(jsonBytes).convertTo[GeoJSON](geoJSONJsonFormat) @Benchmark def uPickle(): GeoJSON = read[GeoJSON](jsonBytes) @Benchmark def weePickle(): GeoJSON = FromJson(jsonBytes).transform(ToScala[GeoJSON]) }
Example 120
Source File: ArrayOfLongsWriting.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.ToJson import com.rallyhealth.weepickle.v1.WeePickle.FromScala import io.circe.syntax._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ class ArrayOfLongsWriting extends ArrayOfLongsBenchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringOutput.write(obj).getBytes(UTF_8) @Benchmark def borer(): Array[Byte] = io.bullet.borer.Json.encode(obj).toByteArray @Benchmark def circe(): Array[Byte] = printer.print(obj.asJson).getBytes(UTF_8) @Benchmark def dslJsonScala(): Array[Byte] = dslJsonEncode(obj) @Benchmark def jacksonScala(): Array[Byte] = jacksonMapper.writeValueAsBytes(obj) @Benchmark def jsoniterScala(): Array[Byte] = writeToArray(obj) @Benchmark def jsoniterScalaPrealloc(): Int = writeToSubArray(obj, preallocatedBuf, 0, preallocatedBuf.length) @Benchmark def playJson(): Array[Byte] = Json.toBytes(Json.toJson(obj)) @Benchmark def sprayJson(): Array[Byte] = obj.toJson.compactPrint.getBytes(UTF_8) @Benchmark def uPickle(): Array[Byte] = write(obj).getBytes(UTF_8) @Benchmark def weePickle(): Array[Byte] = FromScala(obj).transform(ToJson.bytes) }
Example 121
Source File: PrimitivesWriting.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ //import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.PlayJsonFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.WeePickleFromTos._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.ToJson import com.rallyhealth.weepickle.v1.WeePickle.FromScala import io.circe.syntax._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ class PrimitivesWriting extends PrimitivesBenchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringOutput.write(obj).getBytes(UTF_8) @Benchmark def borer(): Array[Byte] = io.bullet.borer.Json.encode(obj).toByteArray @Benchmark def circe(): Array[Byte] = printer.print(obj.asJson).getBytes(UTF_8) @Benchmark def jacksonScala(): Array[Byte] = jacksonMapper.writeValueAsBytes(obj) @Benchmark def jsoniterScala(): Array[Byte] = writeToArray(obj) @Benchmark def jsoniterScalaPrealloc(): Int = writeToSubArray(obj, preallocatedBuf, 0, preallocatedBuf.length) @Benchmark def playJson(): Array[Byte] = Json.toBytes(Json.toJson(obj)) @Benchmark def sprayJson(): Array[Byte] = obj.toJson.compactPrint.getBytes(UTF_8) @Benchmark def uPickle(): Array[Byte] = write(obj).getBytes(UTF_8) @Benchmark def weePickle(): Array[Byte] = FromScala(obj).transform(ToJson.bytes) }
Example 122
Source File: StringOfNonAsciiCharsWriting.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.ToJson import com.rallyhealth.weepickle.v1.WeePickle.FromScala import io.circe.syntax._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import upickle.default._ class StringOfNonAsciiCharsWriting extends StringOfNonAsciiCharsBenchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringOutput.write(obj).getBytes(UTF_8) @Benchmark def borer(): Array[Byte] = io.bullet.borer.Json.encode(obj).toByteArray @Benchmark def circe(): Array[Byte] = printer.print(obj.asJson).getBytes(UTF_8) @Benchmark def dslJsonScala(): Array[Byte] = dslJsonEncode(obj)(stringEncoder) @Benchmark def jacksonScala(): Array[Byte] = jacksonMapper.writeValueAsBytes(obj) @Benchmark def jsoniterScala(): Array[Byte] = writeToArray(obj)(stringCodec) @Benchmark def jsoniterScalaPrealloc(): Int = writeToSubArray(obj, preallocatedBuf, 0, preallocatedBuf.length)(stringCodec) @Benchmark def playJson(): Array[Byte] = Json.toBytes(Json.toJson(obj)) @Benchmark def sprayJson(): Array[Byte] = { import spray.json._ obj.toJson.compactPrint.getBytes(UTF_8) } @Benchmark def uPickle(): Array[Byte] = write(obj).getBytes(UTF_8) @Benchmark def weePickle(): Array[Byte] = FromScala(obj).transform(ToJson.bytes) }
Example 123
Source File: ArrayOfBytesReading.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ //import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.FromJson import com.rallyhealth.weepickle.v1.WeePickle.ToScala import io.circe.parser._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ import upickle.default._ class ArrayOfBytesReading extends ArrayOfBytesBenchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringInput.read[Array[Byte]](new String(jsonBytes, UTF_8)) @Benchmark def borer(): Array[Byte] = io.bullet.borer.Json.decode(jsonBytes).to[Array[Byte]](byteArrayDec).value @Benchmark def circe(): Array[Byte] = decode[Array[Byte]](new String(jsonBytes, UTF_8)).fold(throw _, identity) @Benchmark def jacksonScala(): Array[Byte] = jacksonByteArrayMapper.readValue[Array[Byte]](jsonBytes) @Benchmark def jsoniterScala(): Array[Byte] = readFromArray[Array[Byte]](jsonBytes) @Benchmark def playJson(): Array[Byte] = Json.parse(jsonBytes).as[Array[Byte]] @Benchmark def sprayJson(): Array[Byte] = JsonParser(jsonBytes).convertTo[Array[Byte]] @Benchmark def uPickle(): Array[Byte] = read[Array[Byte]](jsonBytes) @Benchmark def weePickle(): Array[Byte] = FromJson(jsonBytes).transform(ToScala[Array[Byte]]) }
Example 124
Source File: Base64Reading.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json.JsonStringInput import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.core.readFromArray import com.rallyhealth.weejson.v1.jackson.FromJson import com.rallyhealth.weepickle.v1.WeePickle.ToScala import io.circe.parser.decode import org.openjdk.jmh.annotations.Benchmark class Base64Reading extends Base64Benchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringInput.read[Array[Byte]](new String(jsonBytes, UTF_8), jsonBase64Options) @Benchmark def borer(): Array[Byte] = io.bullet.borer.Json.decode(jsonBytes).to[Array[Byte]].value @Benchmark def circe(): Array[Byte] = decode[Array[Byte]](new String(jsonBytes, UTF_8))(base64D5r).fold(throw _, identity) @Benchmark def dslJsonScala(): Array[Byte] = dslJsonDecode[Array[Byte]](jsonBytes) @Benchmark def jacksonScala(): Array[Byte] = jacksonMapper.readValue[Array[Byte]](jsonBytes) @Benchmark def jsoniterScala(): Array[Byte] = readFromArray[Array[Byte]](jsonBytes, tooLongStringConfig)(base64Codec) @Benchmark def weePickle(): Array[Byte] = FromJson(jsonBytes).transform(ToScala[Array[Byte]]) }
Example 125
Source File: ArrayOfLongsReading.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.FromJson import com.rallyhealth.weepickle.v1.WeePickle.ToScala import io.circe.parser._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ class ArrayOfLongsReading extends ArrayOfLongsBenchmark { @Benchmark def avSystemGenCodec(): Array[Long] = JsonStringInput.read[Array[Long]](new String(jsonBytes, UTF_8)) @Benchmark def borer(): Array[Long] = io.bullet.borer.Json.decode(jsonBytes).to[Array[Long]].value @Benchmark def circe(): Array[Long] = decode[Array[Long]](new String(jsonBytes, UTF_8)).fold(throw _, identity) @Benchmark def dslJsonScala(): Array[Long] = dslJsonDecode[Array[Long]](jsonBytes) @Benchmark def jacksonScala(): Array[Long] = jacksonMapper.readValue[Array[Long]](jsonBytes) @Benchmark def jsoniterScala(): Array[Long] = readFromArray[Array[Long]](jsonBytes) @Benchmark def playJson(): Array[Long] = Json.parse(jsonBytes).as[Array[Long]] @Benchmark def sprayJson(): Array[Long] = JsonParser(jsonBytes).convertTo[Array[Long]] @Benchmark def uPickle(): Array[Long] = read[Array[Long]](jsonBytes) @Benchmark def weePickle(): Array[Long] = FromJson(jsonBytes).transform(ToScala[Array[Long]]) }
Example 126
Source File: ArrayOfShortsWriting.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.ToJson import com.rallyhealth.weepickle.v1.WeePickle.FromScala import io.circe.syntax._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ import upickle.default._ class ArrayOfShortsWriting extends ArrayOfShortsBenchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringOutput.write(obj).getBytes(UTF_8) @Benchmark def borer(): Array[Byte] = io.bullet.borer.Json.encode(obj).toByteArray @Benchmark def circe(): Array[Byte] = printer.print(obj.asJson).getBytes(UTF_8) @Benchmark def dslJsonScala(): Array[Byte] = dslJsonEncode(obj) @Benchmark def jacksonScala(): Array[Byte] = jacksonMapper.writeValueAsBytes(obj) @Benchmark def jsoniterScala(): Array[Byte] = writeToArray(obj) @Benchmark def jsoniterScalaPrealloc(): Int = writeToSubArray(obj, preallocatedBuf, 0, preallocatedBuf.length) @Benchmark def playJson(): Array[Byte] = Json.toBytes(Json.toJson(obj)) @Benchmark def sprayJson(): Array[Byte] = obj.toJson.compactPrint.getBytes(UTF_8) @Benchmark def uPickle(): Array[Byte] = write(obj).getBytes(UTF_8) @Benchmark def weePickle(): Array[Byte] = FromScala(obj).transform(ToJson.bytes) }
Example 127
Source File: AnyValsReading.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.FlatSprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.PlayJsonFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.WeePickleFromTos._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.FromJson import com.rallyhealth.weepickle.v1.WeePickle.ToScala import io.circe.parser._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ class AnyValsReading extends AnyValsBenchmark { @Benchmark def avSystemGenCodec(): AnyVals = JsonStringInput.read[AnyVals](new String(jsonBytes, UTF_8)) @Benchmark def borer(): AnyVals = io.bullet.borer.Json.decode(jsonBytes).to[AnyVals].value @Benchmark def circe(): AnyVals = decode[AnyVals](new String(jsonBytes, UTF_8)).fold(throw _, identity) @Benchmark def jacksonScala(): AnyVals = jacksonMapper.readValue[AnyVals](jsonBytes) @Benchmark def jsoniterScala(): AnyVals = readFromArray[AnyVals](jsonBytes) @Benchmark def playJson(): AnyVals = Json.parse(jsonBytes).as[AnyVals] @Benchmark def sprayJson(): AnyVals = JsonParser(jsonBytes).convertTo[AnyVals] @Benchmark def uPickle(): AnyVals = read[AnyVals](jsonBytes) @Benchmark def weePickle(): AnyVals = FromJson(jsonBytes).transform(ToScala[AnyVals]) }
Example 128
Source File: BigDecimalReading.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.FromJson import com.rallyhealth.weepickle.v1.WeePickle.ToScala import io.circe.parser._ import org.openjdk.jmh.annotations.Benchmark //import play.api.libs.json.Json import spray.json._ class BigDecimalReading extends BigDecimalBenchmark { @Benchmark def avSystemGenCodec(): BigDecimal = JsonStringInput.read[BigDecimal](new String(jsonBytes, UTF_8), jsonOptions) @Benchmark def borer(): BigDecimal = io.bullet.borer.Json.decode(jsonBytes).withConfig(decodingConfig).to[BigDecimal].value @Benchmark def circe(): BigDecimal = decode[BigDecimal](new String(jsonBytes, UTF_8)).fold(throw _, identity) @Benchmark def dslJsonScala(): BigDecimal = dslJsonDecode[BigDecimal](jsonBytes) @Benchmark def jacksonScala(): BigDecimal = jacksonMapper.readValue[BigDecimal](jsonBytes) @Benchmark def jsoniterScala(): BigDecimal = readFromArray[BigDecimal](jsonBytes)(bigDecimalCodec) @Benchmark def sprayJson(): BigDecimal = JsonParser(jsonBytes, jsonParserSettings).convertTo[BigDecimal] @Benchmark def uPickle(): BigDecimal = read[BigDecimal](jsonBytes) @Benchmark def weePickle(): BigDecimal = FromJson(jsonBytes).transform(ToScala[BigDecimal]) }
Example 129
Source File: ArrayOfLocalDateTimesReading.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import java.time.LocalDateTime import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.FromJson import com.rallyhealth.weepickle.v1.WeePickle.ToScala import io.circe.parser._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ class ArrayOfLocalDateTimesReading extends ArrayOfLocalDateTimesBenchmark { @Benchmark def avSystemGenCodec(): Array[LocalDateTime] = JsonStringInput.read[Array[LocalDateTime]](new String(jsonBytes, UTF_8)) @Benchmark def borer(): Array[LocalDateTime] = io.bullet.borer.Json.decode(jsonBytes).to[Array[LocalDateTime]].value @Benchmark def circe(): Array[LocalDateTime] = decode[Array[LocalDateTime]](new String(jsonBytes, UTF_8)).fold(throw _, identity) @Benchmark def dslJsonScala(): Array[LocalDateTime] = dslJsonDecode[Array[LocalDateTime]](jsonBytes) @Benchmark def jacksonScala(): Array[LocalDateTime] = jacksonMapper.readValue[Array[LocalDateTime]](jsonBytes) @Benchmark def jsoniterScala(): Array[LocalDateTime] = readFromArray[Array[LocalDateTime]](jsonBytes) @Benchmark def playJson(): Array[LocalDateTime] = Json.parse(jsonBytes).as[Array[LocalDateTime]] @Benchmark def sprayJson(): Array[LocalDateTime] = JsonParser(jsonBytes).convertTo[Array[LocalDateTime]] @Benchmark def uPickle(): Array[LocalDateTime] = read[Array[LocalDateTime]](jsonBytes) @Benchmark def weePickle(): Array[LocalDateTime] = FromJson(jsonBytes).transform(ToScala[Array[LocalDateTime]]) }
Example 130
Source File: IntMapOfBooleansWriting.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ //import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.PlayJsonFormats._ import com.github.plokhotnyuk.jsoniter_scala.core._ import io.circe.syntax._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json class IntMapOfBooleansWriting extends IntMapOfBooleansBenchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringOutput.write(obj).getBytes(UTF_8) @Benchmark def circe(): Array[Byte] = printer.print(obj.asJson).getBytes(UTF_8) @Benchmark def jacksonScala(): Array[Byte] = jacksonMapper.writeValueAsBytes(obj) @Benchmark def jsoniterScala(): Array[Byte] = writeToArray(obj) @Benchmark def jsoniterScalaPrealloc(): Int = writeToSubArray(obj, preallocatedBuf, 0, preallocatedBuf.length) @Benchmark def playJson(): Array[Byte] = Json.toBytes(Json.toJson(obj)) }
Example 131
Source File: MapOfIntsToBooleansReading.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.PlayJsonFormats._ //import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.core._ import io.circe.parser._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json //import upickle.default._ //import spray.json._ import scala.collection.immutable.Map class MapOfIntsToBooleansReading extends MapOfIntsToBooleansBenchmark { @Benchmark def avSystemGenCodec(): Map[Int, Boolean] = JsonStringInput.read[Map[Int, Boolean]](new String(jsonBytes, UTF_8)) @Benchmark def circe(): Map[Int, Boolean] = decode[Map[Int, Boolean]](new String(jsonBytes, UTF_8)).fold(throw _, identity) @Benchmark def dslJsonScala(): Map[Int, Boolean] = dslJsonDecode[Map[Int, Boolean]](jsonBytes) @Benchmark def jacksonScala(): Map[Int, Boolean] = jacksonMapper.readValue[Map[Int, Boolean]](jsonBytes) @Benchmark def jsoniterScala(): Map[Int, Boolean] = readFromArray[Map[Int, Boolean]](jsonBytes) @Benchmark def playJson(): Map[Int, Boolean] = Json.parse(jsonBytes).as[Map[Int, Boolean]] }
Example 132
Source File: ArrayOfBigIntsWriting.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ //import com.github.plokhotnyuk.jsoniter_scala.benchmark.PlayJsonFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.core._ //import com.rallyhealth.weejson.v1.jackson.ToJson //import com.rallyhealth.weepickle.v1.WeePickle.FromScala //import play.api.libs.json.Json import io.circe.syntax._ import org.openjdk.jmh.annotations.Benchmark import spray.json._ class ArrayOfBigIntsWriting extends ArrayOfBigIntsBenchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringOutput.write(obj).getBytes(UTF_8) @Benchmark def borer(): Array[Byte] = io.bullet.borer.Json.encode(obj).toByteArray @Benchmark def circe(): Array[Byte] = printer.print(obj.asJson).getBytes(UTF_8) @Benchmark def dslJsonScala(): Array[Byte] = dslJsonEncode(obj) @Benchmark def jacksonScala(): Array[Byte] = jacksonMapper.writeValueAsBytes(obj) @Benchmark def jsoniterScala(): Array[Byte] = writeToArray(obj) @Benchmark def jsoniterScalaPrealloc(): Int = writeToSubArray(obj, preallocatedBuf, 0, preallocatedBuf.length) }
Example 133
Source File: ArrayOfOffsetTimesReading.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import java.time.OffsetTime import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.PlayJsonFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.core._ import io.circe.parser._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ class ArrayOfOffsetTimesReading extends ArrayOfOffsetTimesBenchmark { @Benchmark def avSystemGenCodec(): Array[OffsetTime] = JsonStringInput.read[Array[OffsetTime]](new String(jsonBytes, UTF_8)) @Benchmark def borer(): Array[OffsetTime] = io.bullet.borer.Json.decode(jsonBytes).to[Array[OffsetTime]].value @Benchmark def circe(): Array[OffsetTime] = decode[Array[OffsetTime]](new String(jsonBytes, UTF_8)).fold(throw _, identity) @Benchmark def dslJsonScala(): Array[OffsetTime] = dslJsonDecode[Array[OffsetTime]](jsonBytes) @Benchmark def jacksonScala(): Array[OffsetTime] = jacksonMapper.readValue[Array[OffsetTime]](jsonBytes) @Benchmark def jsoniterScala(): Array[OffsetTime] = readFromArray[Array[OffsetTime]](jsonBytes) @Benchmark def playJson(): Array[OffsetTime] = Json.parse(jsonBytes).as[Array[OffsetTime]] @Benchmark def sprayJson(): Array[OffsetTime] = JsonParser(jsonBytes).convertTo[Array[OffsetTime]] @Benchmark def uPickle(): Array[OffsetTime] = read[Array[OffsetTime]](jsonBytes) }
Example 134
Source File: SetOfIntsWriting.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.ToJson import com.rallyhealth.weepickle.v1.WeePickle.FromScala import io.circe.syntax._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ import upickle.default._ class SetOfIntsWriting extends SetOfIntsBenchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringOutput.write(obj).getBytes(UTF_8) @Benchmark def borer(): Array[Byte] = io.bullet.borer.Json.encode(obj).toByteArray @Benchmark def circe(): Array[Byte] = printer.print(obj.asJson).getBytes(UTF_8) @Benchmark def dslJsonScala(): Array[Byte] = dslJsonEncode(obj) @Benchmark def jacksonScala(): Array[Byte] = jacksonMapper.writeValueAsBytes(obj) @Benchmark def jsoniterScala(): Array[Byte] = writeToArray(obj) @Benchmark def jsoniterScalaPrealloc(): Int = writeToSubArray(obj, preallocatedBuf, 0, preallocatedBuf.length) @Benchmark def playJson(): Array[Byte] = Json.toBytes(Json.toJson(obj)) @Benchmark def sprayJson(): Array[Byte] = obj.toJson.compactPrint.getBytes(UTF_8) @Benchmark def uPickle(): Array[Byte] = write(obj).getBytes(UTF_8) @Benchmark def weePickle(): Array[Byte] = FromScala(obj).transform(ToJson.bytes) }
Example 135
Source File: MutableBitSetWriting.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.PlayJsonFormats._ import com.github.plokhotnyuk.jsoniter_scala.core._ import io.circe.syntax._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json class MutableBitSetWriting extends MutableBitSetBenchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringOutput.write(obj).getBytes(UTF_8) @Benchmark def circe(): Array[Byte] = printer.print(obj.asJson).getBytes(UTF_8) @Benchmark def dslJsonScala(): Array[Byte] = dslJsonEncode(obj) @Benchmark def jacksonScala(): Array[Byte] = jacksonMapper.writeValueAsBytes(obj) @Benchmark def jsoniterScala(): Array[Byte] = writeToArray(obj) @Benchmark def jsoniterScalaPrealloc(): Int = writeToSubArray(obj, preallocatedBuf, 0, preallocatedBuf.length) @Benchmark def playJson(): Array[Byte] = Json.toBytes(Json.toJson(obj)) }
Example 136
Source File: ArrayOfMonthDaysWriting.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.PlayJsonFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.core._ import io.circe.syntax._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ class ArrayOfMonthDaysWriting extends ArrayOfMonthDaysBenchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringOutput.write(obj).getBytes(UTF_8) @Benchmark def borer(): Array[Byte] = io.bullet.borer.Json.encode(obj).toByteArray @Benchmark def circe(): Array[Byte] = printer.print(obj.asJson).getBytes(UTF_8) @Benchmark def jacksonScala(): Array[Byte] = jacksonMapper.writeValueAsBytes(obj) @Benchmark def jsoniterScala(): Array[Byte] = writeToArray(obj) @Benchmark def jsoniterScalaPrealloc(): Int = writeToSubArray(obj, preallocatedBuf, 0, preallocatedBuf.length) @Benchmark def playJson(): Array[Byte] = Json.toBytes(Json.toJson(obj)) @Benchmark def sprayJson(): Array[Byte] = obj.toJson.compactPrint.getBytes(UTF_8) @Benchmark def uPickle(): Array[Byte] = write(obj).getBytes(UTF_8) }
Example 137
Source File: ArrayOfLocalDateTimesWriting.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.ToJson import com.rallyhealth.weepickle.v1.WeePickle.FromScala import io.circe.syntax._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ class ArrayOfLocalDateTimesWriting extends ArrayOfLocalDateTimesBenchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringOutput.write(obj).getBytes(UTF_8) @Benchmark def borer(): Array[Byte] = io.bullet.borer.Json.encode(obj).toByteArray @Benchmark def circe(): Array[Byte] = printer.print(obj.asJson).getBytes(UTF_8) @Benchmark def dslJsonScala(): Array[Byte] = dslJsonEncode(obj) @Benchmark def jacksonScala(): Array[Byte] = jacksonMapper.writeValueAsBytes(obj) @Benchmark def jsoniterScala(): Array[Byte] = writeToArray(obj) @Benchmark def jsoniterScalaPrealloc(): Int = writeToSubArray(obj, preallocatedBuf, 0, preallocatedBuf.length) @Benchmark def playJson(): Array[Byte] = Json.toBytes(Json.toJson(obj)) @Benchmark def sprayJson(): Array[Byte] = obj.toJson.compactPrint.getBytes(UTF_8) @Benchmark def uPickle(): Array[Byte] = write(obj).getBytes(UTF_8) @Benchmark def weePickle(): Array[Byte] = FromScala(obj).transform(ToJson.bytes) }
Example 138
Source File: ArrayOfOffsetDateTimesWriting.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.ToJson import com.rallyhealth.weepickle.v1.WeePickle.FromScala import io.circe.syntax._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ class ArrayOfOffsetDateTimesWriting extends ArrayOfOffsetDateTimesBenchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringOutput.write(obj).getBytes(UTF_8) @Benchmark def borer(): Array[Byte] = io.bullet.borer.Json.encode(obj).toByteArray @Benchmark def circe(): Array[Byte] = printer.print(obj.asJson).getBytes(UTF_8) @Benchmark def dslJsonScala(): Array[Byte] = dslJsonEncode(obj) @Benchmark def jacksonScala(): Array[Byte] = jacksonMapper.writeValueAsBytes(obj) @Benchmark def jsoniterScala(): Array[Byte] = writeToArray(obj) @Benchmark def jsoniterScalaPrealloc(): Int = writeToSubArray(obj, preallocatedBuf, 0, preallocatedBuf.length) @Benchmark def playJson(): Array[Byte] = Json.toBytes(Json.toJson(obj)) @Benchmark def sprayJson(): Array[Byte] = obj.toJson.compactPrint.getBytes(UTF_8) @Benchmark def uPickle(): Array[Byte] = write(obj).getBytes(UTF_8) @Benchmark def weePickle(): Array[Byte] = FromScala(obj).transform(ToJson.bytes) }
Example 139
Source File: IntMapOfBooleansReading.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ //import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ //import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.PlayJsonFormats._ import com.github.plokhotnyuk.jsoniter_scala.core._ import io.circe.parser._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import scala.collection.immutable.IntMap class IntMapOfBooleansReading extends IntMapOfBooleansBenchmark { @Benchmark def avSystemGenCodec(): IntMap[Boolean] = JsonStringInput.read[IntMap[Boolean]](new String(jsonBytes, UTF_8)) @Benchmark def circe(): IntMap[Boolean] = decode[IntMap[Boolean]](new String(jsonBytes, UTF_8)).fold(throw _, identity) @Benchmark def jsoniterScala(): IntMap[Boolean] = readFromArray[IntMap[Boolean]](jsonBytes) @Benchmark def playJson(): IntMap[Boolean] = Json.parse(jsonBytes).as[IntMap[Boolean]] }
Example 140
Source File: Base16Writing.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json.JsonStringOutput import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.core.{writeToArray, writeToSubArray} import org.openjdk.jmh.annotations.Benchmark class Base16Writing extends Base16Benchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringOutput.write(obj, jsonBase16Options).getBytes(UTF_8) @Benchmark def borer(): Array[Byte] = io.bullet.borer.Json.encode(obj)(base16Enc).toByteArray @Benchmark def jsoniterScala(): Array[Byte] = writeToArray(obj)(base16Codec) @Benchmark def jsoniterScalaPrealloc(): Int = writeToSubArray(obj, preallocatedBuf, 0, preallocatedBuf.length)(base16Codec) }
Example 141
Source File: ArrayOfJavaEnumsWriting.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.PlayJsonFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.WeePickleFromTos._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.ToJson import com.rallyhealth.weepickle.v1.WeePickle.FromScala import io.circe.syntax._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ class ArrayOfJavaEnumsWriting extends ArrayOfJavaEnumsBenchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringOutput.write(obj).getBytes(UTF_8) @Benchmark def borer(): Array[Byte] = io.bullet.borer.Json.encode(obj).toByteArray @Benchmark def circe(): Array[Byte] = printer.print(obj.asJson).getBytes(UTF_8) @Benchmark def dslJsonScala(): Array[Byte] = dslJsonEncode(obj) @Benchmark def jacksonScala(): Array[Byte] = jacksonMapper.writeValueAsBytes(obj) @Benchmark def jsoniterScala(): Array[Byte] = writeToArray(obj) @Benchmark def jsoniterScalaPrealloc(): Int = writeToSubArray(obj, preallocatedBuf, 0, preallocatedBuf.length) @Benchmark def playJson(): Array[Byte] = Json.toBytes(Json.toJson(obj)) @Benchmark def sprayJson(): Array[Byte] = obj.toJson.compactPrint.getBytes(UTF_8) @Benchmark def uPickle(): Array[Byte] = write(obj).getBytes(UTF_8) @Benchmark def weePickle(): Array[Byte] = FromScala(obj).transform(ToJson.bytes) }
Example 142
Source File: VectorOfBooleansReading.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.FromJson import com.rallyhealth.weepickle.v1.WeePickle.ToScala import io.circe.parser._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ import upickle.default._ class VectorOfBooleansReading extends VectorOfBooleansBenchmark { @Benchmark def avSystemGenCodec(): Vector[Boolean] = JsonStringInput.read[Vector[Boolean]](new String(jsonBytes, UTF_8)) @Benchmark def borer(): Vector[Boolean] = io.bullet.borer.Json.decode(jsonBytes).to[Vector[Boolean]].value @Benchmark def circe(): Vector[Boolean] = decode[Vector[Boolean]](new String(jsonBytes, UTF_8)).fold(throw _, identity) @Benchmark def dslJsonScala(): Vector[Boolean] = dslJsonDecode[Vector[Boolean]](jsonBytes) @Benchmark def jacksonScala(): Vector[Boolean] = jacksonMapper.readValue[Vector[Boolean]](jsonBytes) @Benchmark def jsoniterScala(): Vector[Boolean] = readFromArray[Vector[Boolean]](jsonBytes) @Benchmark def playJson(): Vector[Boolean] = Json.parse(jsonBytes).as[Vector[Boolean]] @Benchmark def sprayJson(): Vector[Boolean] = JsonParser(jsonBytes).convertTo[Vector[Boolean]] @Benchmark def uPickle(): Vector[Boolean] = read[Vector[Boolean]](jsonBytes) @Benchmark def weePickle(): Vector[Boolean] = FromJson(jsonBytes).transform(ToScala[Vector[Boolean]]) }
Example 143
Source File: ArrayOfCharsWriting.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.PlayJsonFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.ToJson import com.rallyhealth.weepickle.v1.WeePickle.FromScala import io.circe.syntax._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ import upickle.default._ class ArrayOfCharsWriting extends ArrayOfCharsBenchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringOutput.write(obj).getBytes(UTF_8) @Benchmark def borer(): Array[Byte] = io.bullet.borer.Json.encode(obj).toByteArray @Benchmark def circe(): Array[Byte] = printer.print(obj.asJson).getBytes(UTF_8) @Benchmark def jacksonScala(): Array[Byte] = jacksonMapper.writeValueAsBytes(obj) @Benchmark def jsoniterScala(): Array[Byte] = writeToArray(obj) @Benchmark def jsoniterScalaPrealloc(): Int = writeToSubArray(obj, preallocatedBuf, 0, preallocatedBuf.length) @Benchmark def playJson(): Array[Byte] = Json.toBytes(Json.toJson(obj)) @Benchmark def sprayJson(): Array[Byte] = obj.toJson.compactPrint.getBytes(UTF_8) @Benchmark def uPickle(): Array[Byte] = write(obj).getBytes(UTF_8) @Benchmark def weePickle(): Array[Byte] = FromScala(obj).transform(ToJson.bytes) }
Example 144
Source File: PrimitivesReading.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ //import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.PlayJsonFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.WeePickleFromTos._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.FromJson import com.rallyhealth.weepickle.v1.WeePickle.ToScala import io.circe.parser._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ class PrimitivesReading extends PrimitivesBenchmark { @Benchmark def avSystemGenCodec(): Primitives = JsonStringInput.read[Primitives](new String(jsonBytes, UTF_8)) @Benchmark def borer(): Primitives = io.bullet.borer.Json.decode(jsonBytes).to[Primitives].value @Benchmark def circe(): Primitives = decode[Primitives](new String(jsonBytes, UTF_8)).fold(throw _, identity) @Benchmark def jacksonScala(): Primitives = jacksonMapper.readValue[Primitives](jsonBytes) @Benchmark def jsoniterScala(): Primitives = readFromArray[Primitives](jsonBytes) @Benchmark def playJson(): Primitives = Json.parse(jsonBytes).as[Primitives] @Benchmark def sprayJson(): Primitives = JsonParser(jsonBytes).convertTo[Primitives] @Benchmark def uPickle(): Primitives = read[Primitives](jsonBytes) @Benchmark def weePickle(): Primitives = FromJson(jsonBytes).transform(ToScala[Primitives]) }
Example 145
Source File: ArrayOfYearsWriting.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.PlayJsonFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.core._ import io.circe.syntax._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ class ArrayOfYearsWriting extends ArrayOfYearsBenchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringOutput.write(obj).getBytes(UTF_8) @Benchmark def borer(): Array[Byte] = io.bullet.borer.Json.encode(obj).toByteArray @Benchmark def circe(): Array[Byte] = printer.print(obj.asJson).getBytes(UTF_8) @Benchmark def jacksonScala(): Array[Byte] = jacksonMapper.writeValueAsBytes(obj) @Benchmark def jsoniterScala(): Array[Byte] = writeToArray(obj) @Benchmark def jsoniterScalaPrealloc(): Int = writeToSubArray(obj, preallocatedBuf, 0, preallocatedBuf.length) @Benchmark def playJson(): Array[Byte] = Json.toBytes(Json.toJson(obj)) @Benchmark def sprayJson(): Array[Byte] = obj.toJson.compactPrint.getBytes(UTF_8) @Benchmark def uPickle(): Array[Byte] = write(obj).getBytes(UTF_8) }
Example 146
Source File: ArrayOfYearMonthsReading.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import java.time.YearMonth import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.PlayJsonFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.core._ import io.circe.parser._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ class ArrayOfYearMonthsReading extends ArrayOfYearMonthsBenchmark { @Benchmark def avSystemGenCodec(): Array[YearMonth] = JsonStringInput.read[Array[YearMonth]](new String(jsonBytes, UTF_8)) @Benchmark def borer(): Array[YearMonth] = io.bullet.borer.Json.decode(jsonBytes).to[Array[YearMonth]].value @Benchmark def circe(): Array[YearMonth] = decode[Array[YearMonth]](new String(jsonBytes, UTF_8)).fold(throw _, identity) @Benchmark def jacksonScala(): Array[YearMonth] = jacksonMapper.readValue[Array[YearMonth]](jsonBytes) @Benchmark def jsoniterScala(): Array[YearMonth] = readFromArray[Array[YearMonth]](jsonBytes) @Benchmark def playJson(): Array[YearMonth] = Json.parse(jsonBytes).as[Array[YearMonth]] @Benchmark def sprayJson(): Array[YearMonth] = JsonParser(jsonBytes).convertTo[Array[YearMonth]] @Benchmark def uPickle(): Array[YearMonth] = read[Array[YearMonth]](jsonBytes) }
Example 147
Source File: BitSetWriting.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.PlayJsonFormats._ import com.github.plokhotnyuk.jsoniter_scala.core._ import io.circe.syntax._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json class BitSetWriting extends BitSetBenchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringOutput.write(obj).getBytes(UTF_8) @Benchmark def circe(): Array[Byte] = printer.print(obj.asJson).getBytes(UTF_8) @Benchmark def dslJsonScala(): Array[Byte] = dslJsonEncode(obj) @Benchmark def jacksonScala(): Array[Byte] = jacksonMapper.writeValueAsBytes(obj) @Benchmark def jsoniterScala(): Array[Byte] = writeToArray(obj) @Benchmark def jsoniterScalaPrealloc(): Int = writeToSubArray(obj, preallocatedBuf, 0, preallocatedBuf.length) @Benchmark def playJson(): Array[Byte] = Json.toBytes(Json.toJson(obj)) }
Example 148
Source File: ADTReading.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.PlayJsonFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.WeePickleFromTos._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.FromJson import com.rallyhealth.weepickle.v1.WeePickle.ToScala import io.circe.parser._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ class ADTReading extends ADTBenchmark { @Benchmark def avSystemGenCodec(): ADTBase = JsonStringInput.read[ADTBase](new String(jsonBytes, UTF_8)) @Benchmark def borer(): ADTBase = io.bullet.borer.Json.decode(jsonBytes).to[ADTBase].value @Benchmark def circe(): ADTBase = decode[ADTBase](new String(jsonBytes, UTF_8)).fold(throw _, identity) @Benchmark def jacksonScala(): ADTBase = jacksonMapper.readValue[ADTBase](jsonBytes) @Benchmark def jsoniterScala(): ADTBase = readFromArray[ADTBase](jsonBytes) @Benchmark def playJson(): ADTBase = Json.parse(jsonBytes).as[ADTBase](adtFormat) @Benchmark def sprayJson(): ADTBase = JsonParser(jsonBytes).convertTo[ADTBase](adtBaseJsonFormat) @Benchmark def uPickle(): ADTBase = read[ADTBase](jsonBytes) @Benchmark def weePickle(): ADTBase = FromJson(jsonBytes).transform(ToScala[ADTBase]) }
Example 149
Source File: ArrayOfDoublesReading.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.FromJson import com.rallyhealth.weepickle.v1.WeePickle.ToScala import io.circe.parser._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ class ArrayOfDoublesReading extends ArrayOfDoublesBenchmark { @Benchmark def avSystemGenCodec(): Array[Double] = JsonStringInput.read[Array[Double]](new String(jsonBytes, UTF_8)) @Benchmark def borer(): Array[Double] = io.bullet.borer.Json.decode(jsonBytes).to[Array[Double]].value @Benchmark def circe(): Array[Double] = decode[Array[Double]](new String(jsonBytes, UTF_8)).fold(throw _, identity) @Benchmark def dslJsonScala(): Array[Double] = dslJsonDecode[Array[Double]](jsonBytes) @Benchmark def jacksonScala(): Array[Double] = jacksonMapper.readValue[Array[Double]](jsonBytes) @Benchmark def jsoniterScala(): Array[Double] = readFromArray[Array[Double]](jsonBytes) @Benchmark def playJson(): Array[Double] = Json.parse(jsonBytes).as[Array[Double]] @Benchmark def sprayJson(): Array[Double] = JsonParser(jsonBytes).convertTo[Array[Double]] @Benchmark def uPickle(): Array[Double] = read[Array[Double]](jsonBytes) @Benchmark def weePickle(): Array[Double] = FromJson(jsonBytes).transform(ToScala[Array[Double]]) }
Example 150
Source File: ArrayOfBigIntsReading.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ //import com.github.plokhotnyuk.jsoniter_scala.benchmark.PlayJsonFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.FromJson import com.rallyhealth.weepickle.v1.WeePickle.ToScala //import play.api.libs.json.Json import io.circe.parser._ import org.openjdk.jmh.annotations.Benchmark import spray.json._ class ArrayOfBigIntsReading extends ArrayOfBigIntsBenchmark { @Benchmark def avSystemGenCodec(): Array[BigInt] = JsonStringInput.read[Array[BigInt]](new String(jsonBytes, UTF_8)) @Benchmark def circe(): Array[BigInt] = decode[Array[BigInt]](new String(jsonBytes, UTF_8)).fold(throw _, identity) @Benchmark def borer(): Array[BigInt] = io.bullet.borer.Json.decode(jsonBytes).withConfig(decodingConfig).to[Array[BigInt]].value @Benchmark def dslJsonScala(): Array[BigInt] = dslJsonDecode[Array[BigInt]](jsonBytes) @Benchmark def jacksonScala(): Array[BigInt] = jacksonMapper.readValue[Array[BigInt]](jsonBytes) @Benchmark def jsoniterScala(): Array[BigInt] = readFromArray[Array[BigInt]](jsonBytes) @Benchmark def sprayJson(): Array[BigInt] = JsonParser(jsonBytes).convertTo[Array[BigInt]] @Benchmark def uPickle(): Array[BigInt] = read[Array[BigInt]](jsonBytes) @Benchmark def weePickle(): Array[BigInt] = FromJson(jsonBytes).transform(ToScala[Array[BigInt]]) }
Example 151
Source File: StringOfAsciiCharsReading.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.FromJson import com.rallyhealth.weepickle.v1.WeePickle.ToScala import io.circe.parser._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import upickle.default._ class StringOfAsciiCharsReading extends StringOfAsciiCharsBenchmark { @Benchmark def avSystemGenCodec(): String = JsonStringInput.read[String](new String(jsonBytes, UTF_8)) @Benchmark def borer(): String = io.bullet.borer.Json.decode(jsonBytes).to[String].value @Benchmark def circe(): String = decode[String](new String(jsonBytes, UTF_8)).fold(throw _, identity) @Benchmark def dslJsonScala(): String = dslJsonDecode[String](jsonBytes)(stringDecoder) @Benchmark def jacksonScala(): String = jacksonMapper.readValue[String](jsonBytes) @Benchmark def jsoniterScala(): String = readFromArray[String](jsonBytes, tooLongStringConfig)(stringCodec) @Benchmark def playJson(): String = Json.parse(jsonBytes).as[String] @Benchmark def sprayJson(): String = spray.json.JsonParser(jsonBytes).convertTo[String] @Benchmark def uPickle(): String = read[String](jsonBytes) @Benchmark def weePickle(): String = FromJson(jsonBytes).transform(ToScala[String]) }
Example 152
Source File: ArrayOfZoneIdsWriting.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.core._ import io.circe.syntax._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ class ArrayOfZoneIdsWriting extends ArrayOfZoneIdsBenchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringOutput.write(obj).getBytes(UTF_8) @Benchmark def borer(): Array[Byte] = io.bullet.borer.Json.encode(obj).toByteArray @Benchmark def circe(): Array[Byte] = printer.print(obj.asJson).getBytes(UTF_8) @Benchmark def jacksonScala(): Array[Byte] = jacksonMapper.writeValueAsBytes(obj) @Benchmark def jsoniterScala(): Array[Byte] = writeToArray(obj) @Benchmark def jsoniterScalaPrealloc(): Int = writeToSubArray(obj, preallocatedBuf, 0, preallocatedBuf.length) @Benchmark def playJson(): Array[Byte] = Json.toBytes(Json.toJson(obj)) @Benchmark def sprayJson(): Array[Byte] = obj.toJson.compactPrint.getBytes(UTF_8) @Benchmark def uPickle(): Array[Byte] = write(obj).getBytes(UTF_8) }
Example 153
Source File: ArrayOfYearsReading.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import java.time.Year import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.PlayJsonFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.core._ import io.circe.parser._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ class ArrayOfYearsReading extends ArrayOfYearsBenchmark { @Benchmark def avSystemGenCodec(): Array[Year] = JsonStringInput.read[Array[Year]](new String(jsonBytes, UTF_8)) @Benchmark def borer(): Array[Year] = io.bullet.borer.Json.decode(jsonBytes).to[Array[Year]].value @Benchmark def circe(): Array[Year] = decode[Array[Year]](new String(jsonBytes, UTF_8)).fold(throw _, identity) @Benchmark def jacksonScala(): Array[Year] = jacksonMapper.readValue[Array[Year]](jsonBytes) @Benchmark def jsoniterScala(): Array[Year] = readFromArray[Array[Year]](jsonBytes) @Benchmark def playJson(): Array[Year] = Json.parse(jsonBytes).as[Array[Year]] @Benchmark def sprayJson(): Array[Year] = JsonParser(jsonBytes).convertTo[Array[Year]] @Benchmark def uPickle(): Array[Year] = read[Array[Year]](jsonBytes) }
Example 154
Source File: NestedStructsReading.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ //import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.PlayJsonFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.WeePickleFromTos._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.FromJson import com.rallyhealth.weepickle.v1.WeePickle.ToScala import io.circe.parser._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ class NestedStructsReading extends NestedStructsBenchmark { @Benchmark def avSystemGenCodec(): NestedStructs = JsonStringInput.read[NestedStructs](new String(jsonBytes, UTF_8)) @Benchmark def circe(): NestedStructs = decode[NestedStructs](new String(jsonBytes, UTF_8)).fold(throw _, identity) @Benchmark def dslJsonScala(): NestedStructs = dslJsonDecode[NestedStructs](jsonBytes) @Benchmark def jacksonScala(): NestedStructs = jacksonMapper.readValue[NestedStructs](jsonBytes) @Benchmark def jsoniterScala(): NestedStructs = readFromArray[NestedStructs](jsonBytes) @Benchmark def playJson(): NestedStructs = Json.parse(jsonBytes).as[NestedStructs] @Benchmark def sprayJson(): NestedStructs = JsonParser(jsonBytes).convertTo[NestedStructs](nestedStructsJsonFormat) @Benchmark def uPickle(): NestedStructs = read[NestedStructs](jsonBytes) @Benchmark def weePickle(): NestedStructs = FromJson(jsonBytes).transform(ToScala[NestedStructs]) }
Example 155
Source File: MapOfIntsToBooleansWriting.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.PlayJsonFormats._ //import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.core._ import io.circe.syntax._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json //import upickle.default._ //import spray.json._ class MapOfIntsToBooleansWriting extends MapOfIntsToBooleansBenchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringOutput.write(obj).getBytes(UTF_8) @Benchmark def circe(): Array[Byte] = printer.print(obj.asJson).getBytes(UTF_8) @Benchmark def dslJsonScala(): Array[Byte] = dslJsonEncode(obj) @Benchmark def jacksonScala(): Array[Byte] = jacksonMapper.writeValueAsBytes(obj) @Benchmark def jsoniterScala(): Array[Byte] = writeToArray(obj) @Benchmark def jsoniterScalaPrealloc(): Int = writeToSubArray(obj, preallocatedBuf, 0, preallocatedBuf.length) @Benchmark def playJson(): Array[Byte] = Json.toBytes(Json.toJson(obj)) }
Example 156
Source File: ArrayOfIntsWriting.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.CirceEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.DslPlatformJson._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.core._ import com.rallyhealth.weejson.v1.jackson.ToJson import com.rallyhealth.weepickle.v1.WeePickle.FromScala import io.circe.syntax._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ import upickle.default._ class ArrayOfIntsWriting extends ArrayOfIntsBenchmark { @Benchmark def avSystemGenCodec(): Array[Byte] = JsonStringOutput.write(obj).getBytes(UTF_8) @Benchmark def borer(): Array[Byte] = io.bullet.borer.Json.encode(obj).toByteArray @Benchmark def circe(): Array[Byte] = printer.print(obj.asJson).getBytes(UTF_8) @Benchmark def dslJsonScala(): Array[Byte] = dslJsonEncode(obj) @Benchmark def jacksonScala(): Array[Byte] = jacksonMapper.writeValueAsBytes(obj) @Benchmark def jsoniterScala(): Array[Byte] = writeToArray(obj) @Benchmark def jsoniterScalaPrealloc(): Int = writeToSubArray(obj, preallocatedBuf, 0, preallocatedBuf.length) @Benchmark def playJson(): Array[Byte] = Json.toBytes(Json.toJson(obj)) @Benchmark def sprayJson(): Array[Byte] = obj.toJson.compactPrint.getBytes(UTF_8) @Benchmark def uPickle(): Array[Byte] = write(obj).getBytes(UTF_8) @Benchmark def weePickle(): Array[Byte] = FromScala(obj).transform(ToJson.bytes) }
Example 157
Source File: ArrayOfDurationsReading.scala From jsoniter-scala with MIT License | 5 votes |
package com.github.plokhotnyuk.jsoniter_scala.benchmark import java.nio.charset.StandardCharsets.UTF_8 import java.time.Duration import com.avsystem.commons.serialization.json._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.AVSystemCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.BorerJsonEncodersDecoders._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JacksonSerDesers._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.JsoniterScalaCodecs._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.SprayFormats._ import com.github.plokhotnyuk.jsoniter_scala.benchmark.UPickleReaderWriters._ import com.github.plokhotnyuk.jsoniter_scala.core._ import io.circe.parser._ import org.openjdk.jmh.annotations.Benchmark import play.api.libs.json.Json import spray.json._ class ArrayOfDurationsReading extends ArrayOfDurationsBenchmark { @Benchmark def avSystemGenCodec(): Array[Duration] = JsonStringInput.read[Array[Duration]](new String(jsonBytes, UTF_8)) @Benchmark def borer(): Array[Duration] = io.bullet.borer.Json.decode(jsonBytes).to[Array[Duration]].value @Benchmark def circe(): Array[Duration] = decode[Array[Duration]](new String(jsonBytes, UTF_8)).fold(throw _, identity) @Benchmark def jacksonScala(): Array[Duration] = jacksonMapper.readValue[Array[Duration]](jsonBytes) @Benchmark def jsoniterScala(): Array[Duration] = readFromArray[Array[Duration]](jsonBytes) @Benchmark def playJson(): Array[Duration] = Json.parse(jsonBytes).as[Array[Duration]] @Benchmark def sprayJson(): Array[Duration] = JsonParser(jsonBytes).convertTo[Array[Duration]] @Benchmark def uPickle(): Array[Duration] = read[Array[Duration]](jsonBytes) }