Skip to content

Instantly share code, notes, and snippets.

View plokhotnyuk's full-sized avatar

Andriy Plokhotnyuk plokhotnyuk

View GitHub Profile
Executor service type: akka-forkjoin-pool
Enqueueing:
40,000,000 ops
1,224,743,717 ns
32,659,894 ops/s
25.5 % of CPU usage
24 bytes per instance
Dequeueing:
@plokhotnyuk
plokhotnyuk / ArrayOfOptionBenchmark.scala
Last active April 6, 2018 09:55
Option.fold alternatives in a loop over an array of options
/*
[info] Benchmark (distribution) Mode Cnt Score Error Units
[info] ArrayOfOptionBenchmark.fold AllNone thrpt 5 27250400.765 ± 645700.634 ops/s
[info] ArrayOfOptionBenchmark.fold:·gc.alloc.rate AllNone thrpt 5 ≈ 10⁻⁴ MB/sec
[info] ArrayOfOptionBenchmark.fold:·gc.alloc.rate.norm AllNone thrpt 5 ≈ 10⁻⁵ B/op
[info] ArrayOfOptionBenchmark.fold:·gc.count AllNone thrpt 5 ≈ 0 counts
[info] ArrayOfOptionBenchmark.fold BothPseudoRandom thrpt 5 7220462.819 ± 491274.950 ops/s
[info] ArrayOfOptionBenchmark.fold:·gc.alloc.rate BothPseudoRandom thrpt 5 ≈ 10⁻⁴ MB/sec
[info] ArrayOfOptionBenchmark.fold
[info] final class $anon extends JsonValueCodec[com.github.plokhotnyuk.jsoniter_scala.macros.JsonSchemaAST.Root] {
[info] def nullValue: com.github.plokhotnyuk.jsoniter_scala.macros.JsonSchemaAST.Root = null;
[info] def decodeValue(in: JsonReader, default: com.github.plokhotnyuk.jsoniter_scala.macros.JsonSchemaAST.Root): com.github.plokhotnyuk.jsoniter_scala.macros.JsonSchemaAST.Root = d0(in, default);
[info] def encodeValue(x: com.github.plokhotnyuk.jsoniter_scala.macros.JsonSchemaAST.Root, out: JsonWriter): Unit = e0(x, out);
[info] private[this] val r0: Array[String] = Array("$schema", "type");
[info] private[this] val r1: Array[String] = Array("type");
[info] private[this] val r2: Array[String] = Array("type");
[info] private[this] val r3: Array[String] = Array("type", "items");
[info] private[this] val r4: Array[String] = Array("type");
[info] private[this] def d4(in: JsonReader, default: Option[String]): Option[String] = if (in.isNextToken('n'))
@plokhotnyuk
plokhotnyuk / gist:1e2ee19d3cc80c3644bc9e453c8aae77
Created May 8, 2018 18:12
Long method with lookup/table switch, that generated by Scala macros
private[this] def d10(in: JsonReader, default: com.github.plokhotnyuk.jsoniter_scala.macros.User): com.github.plokhotnyuk.jsoniter_scala.macros.User = if (in.isNextToken('{'))
{
var _id: Long = 0L;
var _id_str: String = null;
var _name: String = null;
var _screen_name: String = null;
var _location: String = null;
var _description: String = null;
var _url: String = null;
var _entities: com.github.plokhotnyuk.jsoniter_scala.macros.UserEntities = null;
This file has been truncated, but you can view the full file.
[info] Loading settings from idea.sbt ...
[info] Loading global plugins from /home/andriy/.sbt/1.0/plugins
[info] Loading settings from plugins.sbt ...
[info] Loading project definition from /home/andriy/Projects/com/github/plokhotnyuk/json-bench-1/project
[info] Loading settings from build.sbt ...
[info] Set current project to json-bench (in build file:/home/andriy/Projects/com/github/plokhotnyuk/json-bench-1/)
[info] Updating ...
[info] Done updating.
[info] Formatting 1 Scala source in json-bench-1:sbt ...
[success] Total time: 2 s, completed May 22, 2018 3:58:50 AM
This file has been truncated, but you can view the full file.
[
{
"jmhVersion" : "1.21",
"benchmark" : "bench.Case1.decodeArgonaut",
"mode" : "thrpt",
"threads" : 1,
"forks" : 2,
"jvm" : "/usr/lib/jvm/java-8-oracle/jre/bin/java",
"jvmArgs" : [
"-server",
| Msg |BooPickle| Chill | CBOR | Smile | Thrift | JSON |ProtoBuf | Kryo |Pickling | Scrooge |Java Ser.|
|-----------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|
| Site 1k | 555 | 908 | 877 | 843 | 561 | 1017 | 554 | 573 | 1681 | 561 | 2207 |
| Site 2k | 1165 | 1695 | 1737 | 1563 | 1175 | 2046 | 1175 | 1177 | 2989 | 1175 | 3311 |
| Site 4k | 1917 | 2507 | 3246 | 2604 | 1937 | 3981 | 1930 | 1950 | 6000 | 1937 | 4549 |
| Site 8k | 3047 | 3644 | 6120 | 4342 | 3071 | 7743 | 3058 | 3096 | 13034 | 3069 | 6615 |
| Site 64k | 25769 | 26260 | 49689 | 34259 | 26803 | 64493 | 27111 | 24978 | 106901 | 26823 | 43168 |
| Events 1k | 593 | 588 | 1063 | 1127 | 592 | 1277 | 578 | 631 | 1565 | 592 | 2716 |
| Events 2k | 1220 | 1260
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.