J
JackRazz
Hi everyone,
I'm trying to figure out an efficient way to check a bunch of objects in a collection
to see if they have changed. They are all different types inherited from a base
class. One possiblility is to stream each object to memory and then compute a CRC
for that item. I can then compare to the original CRC. I profiled a routine to
stream them (see below), but it appears to be far too slow. The CRC computation time
was fine.
Does anyone see anything wrong with this code from a performance perspective. For
example, I could write the object directly to a memory stream with stream.Write(
buffer, offset, count ), but I don't know the object's size.
Any ideas - JackRazz
Public Shared Function ObjToMemStream(ByVal aControlSetting As
ControlSettingBase) As System.IO.MemoryStream
Dim stream As New System.IO.MemoryStream(256)
Dim bytes() As Byte
Dim bFormatter As New
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter()
bFormatter.Serialize(stream, Obj)
End Function
I'm trying to figure out an efficient way to check a bunch of objects in a collection
to see if they have changed. They are all different types inherited from a base
class. One possiblility is to stream each object to memory and then compute a CRC
for that item. I can then compare to the original CRC. I profiled a routine to
stream them (see below), but it appears to be far too slow. The CRC computation time
was fine.
Does anyone see anything wrong with this code from a performance perspective. For
example, I could write the object directly to a memory stream with stream.Write(
buffer, offset, count ), but I don't know the object's size.
Any ideas - JackRazz
Public Shared Function ObjToMemStream(ByVal aControlSetting As
ControlSettingBase) As System.IO.MemoryStream
Dim stream As New System.IO.MemoryStream(256)
Dim bytes() As Byte
Dim bFormatter As New
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter()
bFormatter.Serialize(stream, Obj)
End Function