473,387 Members | 1,534 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,387 software developers and data experts.

Slowness in Serialize

I've got an ArrayList of objects that I'd like to save/retrieve as quickly
as possible. Each item in the arraylist is an object with about 50
variable-length strings; many zero-length, some about 80 chars or so,
if that matters.

I figured I'd set the [Serializable] attribute on the object and on the
ArrayList and use standard Serialize() functions. This is just incredibly
slow. Is that normal? Any other recommended approach?

The function itself is listed below, but I think it's boilerplate:

private bool Serialize(string Filename) {
FileStream binfs;
IFormatter ifmtr = new BinaryFormatter();
bool retval = true;
binfs = new FileStream(
Filename, // expect full path and file name
FileMode.Create,
FileAccess.Write,
FileShare.None);
try {
ifmtr.Serialize(binfs, this);
binfs.Close();
} catch (SerializationException ex) {
// MessageBox.Show(ex.ToString());
retval = false;
}
return retval;
}
Jul 21 '05 #1
4 1422
Usually the *first time is really slow cause the assembly is loaded. The
next times should be faster. Serialization is still going to be a bit slow.
I think they made some improvements in Whidbey.

--
William Stacey, MVP
http://mvp.support.microsoft.com

"_BNC" <_B**@nospam.net> wrote in message
news:q0********************************@4ax.com...
I've got an ArrayList of objects that I'd like to save/retrieve as quickly
as possible. Each item in the arraylist is an object with about 50
variable-length strings; many zero-length, some about 80 chars or so,
if that matters.

I figured I'd set the [Serializable] attribute on the object and on the
ArrayList and use standard Serialize() functions. This is just incredibly
slow. Is that normal? Any other recommended approach?

The function itself is listed below, but I think it's boilerplate:

private bool Serialize(string Filename) {
FileStream binfs;
IFormatter ifmtr = new BinaryFormatter();
bool retval = true;
binfs = new FileStream(
Filename, // expect full path and file name
FileMode.Create,
FileAccess.Write,
FileShare.None);
try {
ifmtr.Serialize(binfs, this);
binfs.Close();
} catch (SerializationException ex) {
// MessageBox.Show(ex.ToString());
retval = false;
}
return retval;
}


Jul 21 '05 #2
Hi,

By default , Serailizable attribute does all the neccessary thing but i
would suggest to control the process of serialization, you can implement the
ISerializable interface and get your things done fast.

Pls go through my this article, which i hope wil help you
http://www.codeproject.com/Purgatory...ion_in_NET.asp

regards
Nishith

"_BNC" wrote:
I've got an ArrayList of objects that I'd like to save/retrieve as quickly
as possible. Each item in the arraylist is an object with about 50
variable-length strings; many zero-length, some about 80 chars or so,
if that matters.

I figured I'd set the [Serializable] attribute on the object and on the
ArrayList and use standard Serialize() functions. This is just incredibly
slow. Is that normal? Any other recommended approach?

The function itself is listed below, but I think it's boilerplate:

private bool Serialize(string Filename) {
FileStream binfs;
IFormatter ifmtr = new BinaryFormatter();
bool retval = true;
binfs = new FileStream(
Filename, // expect full path and file name
FileMode.Create,
FileAccess.Write,
FileShare.None);
try {
ifmtr.Serialize(binfs, this);
binfs.Close();
} catch (SerializationException ex) {
// MessageBox.Show(ex.ToString());
retval = false;
}
return retval;
}

Jul 21 '05 #3
On Mon, 8 Nov 2004 20:04:13 -0500, "William Stacey [MVP]"
<st***********@mvps.org> wrote:
Usually the *first time is really slow cause the assembly is loaded. The
next times should be faster. Serialization is still going to be a bit slow.
I think they made some improvements in Whidbey.


I hope so. I was trying to replace a somewhat slow XML parser (the
original file was a proprietary XML format). I was shocked to find out
that the binary serialize was several times slower at storing the info
than the XML parser. That doesn't make much sense.

Jul 21 '05 #4
No it doesn't. I wonder if something else is going on?

--
William Stacey, MVP
http://mvp.support.microsoft.com

"_BNC" <_B**@nospam.net> wrote in message
news:85********************************@4ax.com...
On Mon, 8 Nov 2004 20:04:13 -0500, "William Stacey [MVP]"
<st***********@mvps.org> wrote:
Usually the *first time is really slow cause the assembly is loaded. The
next times should be faster. Serialization is still going to be a bit slow.I think they made some improvements in Whidbey.


I hope so. I was trying to replace a somewhat slow XML parser (the
original file was a proprietary XML format). I was shocked to find out
that the binary serialize was several times slower at storing the info
than the XML parser. That doesn't make much sense.


Jul 21 '05 #5

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

Similar topics

0
by: Nicole | last post by:
Has anyone else experienced a dramatic slow down of performance with their ADP's after upgrading to Service Pack 2 or above? The slowness occurs exclusively when pulling data from SQL Server in...
5
by: David Sworder | last post by:
Hi, I've created a UserControl-derived class called MyUserControl that is able to persist and subsequently reload its state. It exposes two methods as follows: public void Serialize(Stream...
10
by: Dan | last post by:
All I Am Attempting To Serialize An Object To An XML File. Here Is The Code For That public string SaveNewSurvey( MutualSurveyObject mso_TempObject, int i_JobID ) { string s_RootFileName;...
6
by: _BNC | last post by:
I've got an ArrayList of objects that I'd like to save/retrieve as quickly as possible. Each item in the arraylist is an object with about 50 variable-length strings; many zero-length, some about...
1
by: js | last post by:
Does anybody knows how to solve the problem? I added attribute to the following classes in Microsoft.Practices.EnterpriseLibrary.Data namespace, but I still get the error. Thanks. ...
8
by: cd~ | last post by:
I can provide a test app, the news server won't allow me to post the files because they are too large (93KB and 1.2KB) I downloaded the ESRI ArcXml schema and generated the classes from the...
1
by: Tim | last post by:
Could anyone tell me what this means and how do I correct it. Any suggestions? Thanks! Tim Richardson IT Developer and Consultant www.paladin3d.com Unable to serialize the session state. In...
4
by: =?Utf-8?B?Qnlyb24=?= | last post by:
When I try to serialize an instance of the LocationCell below (note Building field) I get an error in the reflection attempt. If I remove the _Building field it serializes fine. I tried renaming...
9
by: Gillard | last post by:
i get an exeption and i do not know what else to do to continue Dim sdf As New SaveFileDialog With sdf .AddExtension = True .DefaultExt = ".record" .FileName = Now.ToLongDateString .Filter =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.