SceneGate / Yarhl

Framework for the implementation of format converters like game assets or media files
https://scenegate.github.io/Yarhl/
MIT License
60 stars 10 forks source link

Improve performance of DataReader and DataWriter #186

Open pleonex opened 2 years ago

pleonex commented 2 years ago

Is your feature request related to a problem? The performance of the binary reader and writer classes is worse than the .NET alternative BinaryReader / BinaryWriter. The reason is that it doesn't benefit from hardware acceleration features and it creates several buffers (requiring allocation).

Describe the solution you'd like Create a performance test to compare the performance and improve by:

Describe alternatives you've considered Remove the class, but we need it as BinaryReader only supports little-endian decoding.

Additional context These classes impact the performance of most user code. The BinaryReader class has additional performance optimizations detecting if the Stream is MemoryStream and then accessing directly to the byte array with Spans. For now we should skip this kind of optimizations. We can consider them in the future inside DataStream.