c# - How to speed up serialization code? -


I have the following code that serializes a list of one byte array for transport through web services. The code works relatively fast on smaller entities, but it is a list of 60,000 or so items. It takes several seconds to execute the format. Anyway to speed it up? {BinaryFormatter formatter = new BinaryFormatter (empty, new streamingConstex (StreamingContactStustSets.clone)) using the public static byte [] ToBinary (Object objToBinary) {{MemoryStream memStream = New MemoryStream ()) ; Formatter.Serialize (memstream, objToBinary); Memstream.Seek (0, SeekOrigin.Begin); Return memStream.ToArray (); }}

The incompetence you are experiencing comes from many sources: < / P>

  1. Uses the default serialization routine reflection to calculate the object field and get their value.
  2. The binary serialization format stores things in an assistive list made by string names of things.
  3. You got a fake toour (as Danny is mentioned).

You can get a big correction by applying > ISerializable on the object type contained in your list . This will eliminate the default serialization behavior that uses reflections.

If you decrease the number of elements in the cumulative table, you can get a little more speed by holding the serialized data. Make sure that the elements you have stored in that organizational array are primitive types.

Finally, you can terminate ToArray but I suspect you will also see the bump which gives you


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -