summaryrefslogtreecommitdiff
path: root/benchmark/src/jmh/kotlin/kotlinx/benchmarks/ProtoBaseline.kt
diff options
context:
space:
mode:
authorVsevolod Tolstopyatov <qwwdfsad@gmail.com>2020-07-21 13:18:09 -0700
committerGitHub <noreply@github.com>2020-07-21 23:18:09 +0300
commitc136b5697853622914e60bdf941802a662d97e85 (patch)
treeb87eddc079076b4439e97f8dd721c544d8a2b1bd /benchmark/src/jmh/kotlin/kotlinx/benchmarks/ProtoBaseline.kt
parent8654620b8e4b5e2b638deed2943d1206084e885c (diff)
downloadkotlinx.serialization-c136b5697853622914e60bdf941802a662d97e85.tar.gz
ProtoBuf enchancements (#923)
* Do not throw exceptions that are not subtypes of SerializationException on unexpected inputs * Properly encode length for tagless top-level ProtoBuf data * Get rid of dead code * Significantly optimize ProtoBuf nested structures by avoiding an additional copy of nested objects during encoding and decoding Fixes #870 Fixes #93
Diffstat (limited to 'benchmark/src/jmh/kotlin/kotlinx/benchmarks/ProtoBaseline.kt')
-rw-r--r--benchmark/src/jmh/kotlin/kotlinx/benchmarks/ProtoBaseline.kt14
1 files changed, 7 insertions, 7 deletions
diff --git a/benchmark/src/jmh/kotlin/kotlinx/benchmarks/ProtoBaseline.kt b/benchmark/src/jmh/kotlin/kotlinx/benchmarks/ProtoBaseline.kt
index 729b6205..b6f414c4 100644
--- a/benchmark/src/jmh/kotlin/kotlinx/benchmarks/ProtoBaseline.kt
+++ b/benchmark/src/jmh/kotlin/kotlinx/benchmarks/ProtoBaseline.kt
@@ -4,7 +4,7 @@
package kotlinx.benchmarks
-import kotlinx.serialization.Serializable
+import kotlinx.serialization.*
import kotlinx.serialization.protobuf.*
import org.openjdk.jmh.annotations.*
import java.util.concurrent.*
@@ -24,20 +24,20 @@ open class ProtoBaseline {
class HolderExplicit(@ProtoId(1) val a: Int, @ProtoId(2) val b: Int, @ProtoId(3) val c: Long, @ProtoId(4) val d: Double)
private val holder = Holder(1, 2, 3L, 4.0)
- private val holderBytes = ProtoBuf.dump(Holder.serializer(), holder)
+ private val holderBytes = ProtoBuf.encodeToByteArray(Holder.serializer(), holder)
private val holderExplicit = HolderExplicit(1, 2, 3L, 4.0)
- private val holderHolderExplicitBytes = ProtoBuf.dump(HolderExplicit.serializer(), holderExplicit)
+ private val holderHolderExplicitBytes = ProtoBuf.encodeToByteArray(HolderExplicit.serializer(), holderExplicit)
@Benchmark
- fun toBytes() = ProtoBuf.dump(Holder.serializer(), holder)
+ fun toBytes() = ProtoBuf.encodeToByteArray(Holder.serializer(), holder)
@Benchmark
- fun fromBytes() = ProtoBuf.load(Holder.serializer(), holderBytes)
+ fun fromBytes() = ProtoBuf.decodeFromByteArray(Holder.serializer(), holderBytes)
@Benchmark
- fun toBytesExplicit() = ProtoBuf.dump(HolderExplicit.serializer(), holderExplicit)
+ fun toBytesExplicit() = ProtoBuf.encodeToByteArray(HolderExplicit.serializer(), holderExplicit)
@Benchmark
- fun fromBytesExplicit() = ProtoBuf.load(HolderExplicit.serializer(), holderHolderExplicitBytes)
+ fun fromBytesExplicit() = ProtoBuf.decodeFromByteArray(HolderExplicit.serializer(), holderHolderExplicitBytes)
}