Quick benchmark to see the performance difference between the different ways of 'serializing' data to a binary blob in dotnet. For simplicity this only deals with writing 32 bit integers.
Methods this compares:
- Shifting and assigning the four bytes that make up the integer.
- Using
MemoryMarshal
to write the memory. - Directly assigning a reference.
- Directly assigning a pointer.