backtrace-android
backtrace-android copied to clipboard
Custom Backtrace serializer/deserializer - GSON replacement
Important note: First we need to merge PR #144
Summary This PR contains all changes needed to replace GSON library which was used for serialization/deserialization data. These modifications are part of the ongoing efforts to optimize the backtrace-android library by reducing external dependencies and enhancing performance.
Key Changes
- Introduces new manual serialization and deserialization logic tailored for Backtrace data models.
- Eliminates the need for GSON, reducing runtime overhead and potential compatibility issues.
- Add unit tests to check the correctness of serialization and deserialization of the main data models
Performance comparison GSON vs custom solution based on included unit-tests
BacktraceData serialization (SerializerBacktraceDataGsonComparisonTest.java)
[GSON] Average execution time: 2.04 milliseconds
[Org.json] Average execution time: 0.942 milliseconds
Different objects serialization (SerializerGsonComparisonTest.java)
Total serialization time of object type BacktraceApiResult [GSON]: 247 milliseconds, [Org.json]: 57 milliseconds
Total serialization time of object type BacktraceResult [GSON]: 11 milliseconds, [Org.json]: 3 milliseconds
Total serialization time of object type BacktraceReport [GSON]: 5 milliseconds, [Org.json]: 8 milliseconds
Total serialization time of object type BacktraceReport [GSON]: 7 milliseconds, [Org.json]: 11 milliseconds
Total serialization time of object type BacktraceStackFrame [GSON]: 1 milliseconds, [Org.json]: 1 milliseconds
Total serialization time of object type SourceCode [GSON]: 2 milliseconds, [Org.json]: 1 milliseconds
Total serialization time of object type ThreadInformation [GSON]: 2 milliseconds, [Org.json]: 2 milliseconds
Different object deserialization (DeserializerGsonComparisonTest.java)
Total deserialization time [GSON] of object BacktraceApiResult: 120 milliseconds, [Org.json]: 42 milliseconds
Total deserialization time [GSON] of object BacktraceApiResult: 1 milliseconds, [Org.json]: 2 milliseconds
Total deserialization time [GSON] of object BacktraceData: 22 milliseconds, [Org.json]: 22 milliseconds
Total deserialization time [GSON] of object BacktraceReport: 3 milliseconds, [Org.json]: 5 milliseconds
Total deserialization time [GSON] of object BacktraceReport: 6 milliseconds, [Org.json]: 4 milliseconds
Total deserialization time [GSON] of object BacktraceResult: 6 milliseconds, [Org.json]: 6 milliseconds
Total deserialization time [GSON] of object BacktraceStackFrame: 2 milliseconds, [Org.json]: 1 milliseconds
Total deserialization time [GSON] of object SourceCode: 1 milliseconds, [Org.json]: 1 milliseconds
Total deserialization time [GSON] of object ThreadInformation: 2 milliseconds, [Org.json]: 2 milliseconds
Potential breaking changes
- If you are a client of this library and you were using GSON annotation
import com.google.gson.annotations.SerializedName;
you need to replace it withimport backtraceio.library.common.json.serialization.SerializedName;
and verify if your objects are serialized/deserialized correctly before going to production.
Architecture of new serialization/deserialization flow