471,315 Members | 1,508 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,315 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 1011
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.

Similar topics

2 posts views Thread by Meta-Meta | last post: by
2 posts views Thread by Snowman | last post: by
3 posts views Thread by Amadelle | last post: by
6 posts views Thread by Nick Z. | last post: by
3 posts views Thread by AnkitAsDeveloper [Ankit] | last post: by
3 posts views Thread by parrot toes | last post: by
reply views Thread by rosydwin | last post: by

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.