By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,799 Members | 1,356 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,799 IT Pros & Developers. It's quick & easy.

Peformance of Deserialization vs new Object construction

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.