473,322 Members | 1,911 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Peformance of Deserialization vs new Object construction

I have an object that I'm serializing (binary) that contains other internal
objects that are also serialized. The Object contains two other member
objects (let's call them source, and depend) one of which has a state that
depends value is derived from source. My question is (if this can be
generalized) is faster/better to serialize both objects or to only serialize
state and then during deserialization create depend from source.

Option 1:

[Serializable()]
public class Foo
{
object source;

object depend;

protected Foo(SerializationInfo info, StreamingContext context) :
base(info, context)
{
}
}
Option 2:
[Serializable()]
public class Foo
{
object source;

[field:NonSerialized()]
object depend;

protected Foo(SerializationInfo info, StreamingContext context) :
base(info, context)
{
depend = new depend();
depend.State = source.Info;

}
}

Thanks
Jan 9 '06 #1
1 1070
Brian Richards wrote:
I have an object that I'm serializing (binary) that contains other
internal objects that are also serialized. The Object contains two
other member objects (let's call them source, and depend) one of
which has a state that depends value is derived from source. My
question is (if this can be generalized) is faster/better to
serialize both objects or to only serialize state and then during
deserialization create depend from source.

Option 1:

[Serializable()]
public class Foo
{
object source;

object depend;

protected Foo(SerializationInfo info, StreamingContext context) :
base(info, context)
{
}
}
Option 2:
[Serializable()]
public class Foo
{
object source;

[field:NonSerialized()]
object depend;

protected Foo(SerializationInfo info, StreamingContext context) :
base(info, context)
{
depend = new depend();
depend.State = source.Info;

}
}


Deserializing is always slower than simply re-creating the objects by
hand and filling in some data because the code deserializing has to use
is very complex and not straight forward simple as your option2, plus
data has to be interpreted, although the binary formatter uses some
shortcuts to get a blob quickly re-instantiated as an object.

FB

--
------------------------------------------------------------------------
Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
Jan 10 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: TEK | last post by:
There seems to be a bug when deserialization some classes in the .NET framework. If you try to deserialize a class that has a base class that holds a struct with a member that is implementing...
2
by: Meta-Meta | last post by:
Hi, I'm trying to deserialize a VC++ .NET class and am stumped by the following problem : In order to create the XmlSerializer you need to pass the type of the object being created. The doc...
2
by: Snowman | last post by:
Suppose I have a RootObject which holds a collection of other objects. The other objects have a property (Parent) which refers back to the "parent" collection (b.t.w. my collection is based on...
3
by: Amadelle | last post by:
Hi all and thanks in advance for your help, I am having problems deserializing an object which seems to be serializing just fine. I save the byte array of the serialized object in the database...
6
by: Nick Z. | last post by:
I need my program to start as fast as possible. Will deserialization a few settings using binary deserialization affect that? Or should I keep these settings in XML, will that be any better? ...
3
by: AnkitAsDeveloper [Ankit] | last post by:
Hi i am serializing a 'ref struct' object as follows : private: void Seri( String ^path, Object^ obj ) { FileStream^ fileStrm ; try { //Serialize entire object into Binary stream
3
by: parrot toes | last post by:
Summary: I have been trying to make requests of a web service provided by Axis using a dotnet client with code generated by wsdl.exe and have been getting exceptions when trying to process the...
1
by: parrot toes | last post by:
I tried to post this question before, but there was an error when posting. I case it did get posted and in order to avoid duplication, I'll just repost a summary. I have written a dotnet client...
8
by: ashoksrini | last post by:
Hi All, I have the below requirement and would like to get some feeback from the group on the best way to implement: 1. I have WSDL defined exposing few web services. 2. We dont have a...
1
by: Brian Richards | last post by:
I have an object that I'm serializing (binary) that contains other internal objects that are also serialized. The Object contains two other member objects (let's call them source, and depend) one...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.