-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #95 from sphereio/remove_collection_breakout
Remove collection breakout
- Loading branch information
Showing
6 changed files
with
136 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package json | ||
|
||
import io.sphere.json._ | ||
import org.openjdk.jmh.annotations._ | ||
|
||
@State(Scope.Benchmark) | ||
@BenchmarkMode(Array(Mode.Throughput)) | ||
@Warmup(iterations = 10, time = 1) | ||
@Measurement(iterations = 10, time = 1) | ||
@Fork(value = 1) | ||
class FromJsonBenchmark { | ||
|
||
/* on local mac | ||
jmh:run | ||
Benchmark Mode Cnt Score Error Units | ||
FromJsonBenchmark.listReader thrpt 10 66,286 ± 1,025 ops/s | ||
FromJsonBenchmark.parseFromStringToCaseClass thrpt 10 12,974 ± 0,333 ops/s | ||
FromJsonBenchmark.seqReader thrpt 10 66,626 ± 1,235 ops/s | ||
FromJsonBenchmark.vectorReader thrpt 10 67,702 ± 2,501 ops/s | ||
*/ | ||
|
||
@Benchmark | ||
def parseFromStringToCaseClass(): Unit = { | ||
val product = getFromJSON[Product](JsonBenchmark.json) | ||
assert(product.version == 2) | ||
} | ||
|
||
@Benchmark | ||
def vectorReader(): Unit = { | ||
fromJSON[Vector[Int]](JsonBenchmark.lotsOfIntsAsJson) | ||
} | ||
|
||
@Benchmark | ||
def listReader(): Unit = { | ||
fromJSON[List[Int]](JsonBenchmark.lotsOfIntsAsJson) | ||
} | ||
|
||
@Benchmark | ||
def seqReader(): Unit = { | ||
fromJSON[Seq[Int]](JsonBenchmark.lotsOfIntsAsJson) | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package json | ||
|
||
import org.json4s.StringInput | ||
import org.json4s.jackson._ | ||
import org.openjdk.jmh.annotations._ | ||
|
||
@State(Scope.Benchmark) | ||
@BenchmarkMode(Array(Mode.Throughput)) | ||
@Warmup(iterations = 10, time = 1) | ||
@Measurement(iterations = 10, time = 1) | ||
@Fork(value = 1) | ||
class ParseJsonBenchmark { | ||
|
||
/* on local mac | ||
jmh:run | ||
Benchmark Mode Cnt Score Error Units | ||
ParseJsonBenchmark.parseFromStringToJValue thrpt 10 85,322 ± 1,073 ops/s | ||
*/ | ||
|
||
@Benchmark | ||
def parseFromStringToJValue(): Unit = { | ||
val jvalue = parseJson(StringInput(JsonBenchmark.json)) | ||
assert(jvalue != null) | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package json | ||
|
||
import java.util.UUID | ||
|
||
import io.sphere.json._ | ||
import io.sphere.json.generic._ | ||
import io.sphere.util.BaseMoney | ||
import org.json4s.StringInput | ||
import org.json4s.jackson._ | ||
import org.openjdk.jmh.annotations._ | ||
|
||
@State(Scope.Benchmark) | ||
@BenchmarkMode(Array(Mode.Throughput)) | ||
@Warmup(iterations = 10, time = 1) | ||
@Measurement(iterations = 10, time = 1) | ||
@Fork(value = 1) | ||
class ToJsonBenchmark { | ||
|
||
/* on local mac | ||
jmh:run | ||
Benchmark Mode Cnt Score Error Units | ||
ToJsonBenchmark.listWriter thrpt 10 68,770 ± 1,157 ops/s | ||
ToJsonBenchmark.seqWriter thrpt 10 65,792 ± 1,191 ops/s | ||
ToJsonBenchmark.serializeCaseClassToString thrpt 10 39,142 ± 0,574 ops/s | ||
ToJsonBenchmark.vectorWriter thrpt 10 64,359 ± 2,162 ops/s | ||
*/ | ||
|
||
@Benchmark | ||
def serializeCaseClassToString(): Unit = { | ||
val json = toJSON[Product](JsonBenchmark.product) | ||
assert(json != null) | ||
} | ||
|
||
@Benchmark | ||
def vectorWriter(): Unit = { | ||
toJSON[Vector[Int]](JsonBenchmark.lotsOfIntsVector) | ||
} | ||
|
||
@Benchmark | ||
def listWriter(): Unit = { | ||
toJSON[List[Int]](JsonBenchmark.lotsOfIntsList) | ||
} | ||
|
||
@Benchmark | ||
def seqWriter(): Unit = { | ||
toJSON[Seq[Int]](JsonBenchmark.lotsOfIntsSeq) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters