First, it is important that serialization is correct. There are usually no handwritten serializers. For example, they tend to forget that the string "]]>" cannot be displayed in node text.
It's not difficult to write your own serializer, which is correct and fast if you are a compatible Java programmer, but since some very capable Java programmers were here before I think you are unlikely to beat enough of them to put in the effort to write own code.
In addition, it is possible that most general-purpose libraries may slow down a bit by offering serialization options β for example, indentation or coding, or how to choose line endings. You can simply squeeze an extra ounce of performance while avoiding unwanted features.
In addition, some general-purpose libraries can verify that you throw them at the correctness, for example, by checking that namespace prefixes are declared (or are declared if not). You can do it faster if it does not check. On the other hand, you can create a library that is fast, but a pig for work. Performance behavior above all other goals is almost always a mistake.
Regarding the performance of the available libraries, measure them and let us know what you learned.
source share