Closed AArnott closed 1 week ago
Incidentally, upgrading the baseline from MessagePack v2 to v3 produces this:
Method | Mean | Error | StdDev | Ratio | Allocated | Alloc Ratio |
---|---|---|---|---|---|---|
Serialize_TypeShape | 130.9 ns | 0.37 ns | 0.33 ns | 0.95 | - | NA |
Serialize_Library | 137.6 ns | 0.23 ns | 0.21 ns | 1.00 | - | NA |
This improves serialization slightly, making TypeShape fair slightly worse by comparison.
Method | Mean | Error | StdDev | Ratio | Allocated | Alloc Ratio |
---|---|---|---|---|---|---|
Deserialize_TypeShape | 148.1 ns | 0.63 ns | 0.56 ns | 1.21 | 32 B | 1.00 |
Deserialize_Library | 122.2 ns | 0.74 ns | 0.61 ns | 1.00 | 32 B | 1.00 |
Deserialization improves significantly, making TypeShape look quite a bit worse. This is due to using a dictionary to look up property names, which the AOT formatter avoids.
Serialization is somehow faster than the Ref.Emit specialized code produced by the MessagePack library. I don't know how that's possible.
I suspect it's because in this version, we call MessagePackWriter.Write(string)
directly rather than including a level of indirection that allows for some other serializer to hijack that operation at runtime to serialize something else (e.g. so that a string is only serialized once).
@neuecc this should interest you.
This pull request includes updates to the
README.md
file, enhancements to theSpanDictionary
class, and improvements to the equality members of theBaseClass
andDerivedClass
in the test types.Documentation Updates:
README.md
: Added a new section listing known libraries based on TypeShape, includingNerdbank.MessagePack
.Code Enhancements:
src/TypeShape.Examples/Utilities/SpanDictionary.cs
: Added a new overload for theToSpanDictionary
method to support mapping with a value selector.Test Improvements:
tests/TypeShape.Tests/TestTypes.cs
: ImplementedIEquatable<T>
forBaseClass
andDerivedClass
, and added appropriateEquals
andGetHashCode
methods.