jefffhaynes / BinarySerializer

A declarative serialization framework for controlling formatting of data at the byte and bit level using field bindings, converters, and code.
MIT License
292 stars 62 forks source link

Span and Memory #135

Open abrasat opened 5 years ago

abrasat commented 5 years ago

Would the usage of Memory/Span>T> in the BinarySerializer implementation bring any advantages in terms of performance? Is there anything planned in this direction?

jefffhaynes commented 5 years ago

I actually looked at this recently and my feeling is that for the moment it is probably not worth it for two main reasons. First, the project is currently built against .net standard 1.3. The newer memory classes aren't supported until .net standard 2.1 (currently in preview). Second, while performance is important, I think interoperability is much more important. There are other ways of serializing and storing data that will always be superior to this library as the main intent of this library is to make working with non-standards easier. That being said, I think some of the new memory support is very cool and most likely I will revisit this down the road as it spreads into all .net frameworks.

Mephistofeles commented 5 years ago

https://www.nuget.org/packages/System.Memory/ I think they are supported on .NET Standard 2.0, it's just there won't be any performance gains when not running on .NET Core.

jefffhaynes commented 5 years ago

Thanks, good tip. Unfortunately, without span and memory overloads in streams, I'm not sure there is a significant advantage to introducing them. If anyone has any ideas for other places where these would help in the current design I'm happy to try.