Hi,
when i serialize an array of Int32 using the BinaryFormatter, i get about 400MB/s (100 million items in one second), but when i try to serialize an array of DateTime, i get only a throughput of about 27MB/s (100 million items in 30 seconds). One DateTime occupies eight bytes in serialized form. I guess that the BinaryFormatter uses the ISerializable interface, if its implemented, so i had a look at the GetObjectData implementation of the DateTime type:
void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
{
if (info == null)
{
throw new ArgumentNullException("info");
}
info.AddValue("ticks", this.InternalTicks);
info.AddValue("dateData", this.dateData);
}
I am confused that an UInt64 and an Int64 are added to the output, which should be 16 bytes in sum, but that does not reflect my measures. So how is DateTime really serialized to binary?