Closed
Description
Copying over my Android Microbenchmarks results (ran on Google Pixel 3):
Benchmark | Time (ns) | Allocations |
---|---|---|
object_reflection_serializer | 56,077 | 27 |
object_reflection_json | 69,069 | 40 |
object_intrinsic_serializer | 56,211 | 30 |
object_intrinsic_json | 118,768 | 73 |
dataclass_reflection_serializer | 2,450 | 8 |
dataclass_reflection_json | 6,462 | 28 |
dataclass_intrinsic_serializer | 2,687 | 11 |
dataclass_intrinsic_json | 9,927 | 42 |
Also interesting is that the intrinsic is usually (marginally) slower than using reflection.
To Reproduce
All benchmarks are here: https://github.com/chrisbanes/kotlin-serialization-object-perf
Expected behavior
I'd expect objects to be faster than data classes (or at least similar).
Environment
- Kotlin version: 1.7.0
- Library version: 1.3.3 (1.4-RC is very similar numbers though)
- Kotlin platforms: JVM/Android
Metadata
Metadata
Assignees
Labels
No labels