Eduardo Couto Parreiras

Hi guys,

After i translate my message from unicode, i have a method that converts the xml into a dataset, and this process is getting slow, sometimes stuck a little, in first time always get shower than others, but i¡¯ve made some research and found nothing different of my code.

Heres is my code

DataSet dsRet = new DataSet();

dsRet.ReadXmlSchema(new XmlTextReader(new StringReader(xml[0])));
dsRet.ReadXml(new XmlTextReader(new StringReader(xml[1])));

if (dsRet.Tables.Count > 0)
return dsRet.Tables[0].Copy();
else return new DataTable();

What can making it slow/stucking

Thanks anyway...

Eduardo



Re: .NET Compact Framework XML CONVERT TOO SLOW

Ilya Tumanov

Parsing XML is inherently complex and thus slow task, especially noticeable on devices which have only fraction of PC power. To speed it up make XML simpler and smaller if you can. If you¡¯re on NETCF V1 upgrade to NETCF V2, it¡¯s faster. Also consider loading XML as it¡¯s been received, do not load it into the string first. Use typed DataSet so you don¡¯t have to load schema and void DateTime fields as they are very slow to parse.




Re: .NET Compact Framework XML CONVERT TOO SLOW

Eduardo Couto Parreiras

Ok, my netcf is v2, and the conversion im using without xmlreader converter, just string reader; The readxml cannot receive a string directly, so i need to use stringreader, some stream, there another way to convert

Thx





Re: .NET Compact Framework XML CONVERT TOO SLOW

Eduardo Couto Parreiras

Im using like this :

DataSet dsRet = new DataSet();

dsRet.ReadXmlSchema(new StringReader(xml[0]));
dsRet.ReadXml(new StringReader(xml[1]));

if (dsRet.Tables.Count > 0)
return dsRet.Tables[0].Copy();
else return new DataTable();




====

using like this is impossible

dsRet.ReadXmlSchema(xml[0]);
dsRet.ReadXml(xml[1]);






Re: .NET Compact Framework XML CONVERT TOO SLOW

Ilya Tumanov

How did you get this string in a first place I would guess it's not hardcoded in your application but coming from file or network, right So get rid of it and pass that file of stream to DataSet.ReadXml().






Re: .NET Compact Framework XML CONVERT TOO SLOW

Eduardo Couto Parreiras

Yeah, its from network, but i received as string(XML) from my middleware.
I receive from my network and translate from unicode to string, and then i pass to dataset;
My smart device application do not acces the database directly;

We discovered that some components of .net were getting slow, and then we start to usign then less, and we got some best performance, but the exactly convert xml from string, it is like getting stuck for some time.







Re: .NET Compact Framework XML CONVERT TOO SLOW

Ilya Tumanov

So far it looks like you¡¯re mostly creating performance issues yourself by doing extra stuff you don¡¯t have to do and by using memory you don¡¯t have to use. Perhaps it's time to get rid of your middleware and start doing thing more efficiently. Just read data into the DataSet directly, it would be most certainly faster and would use way less memory. Also make sure you¡¯re not doing something like this with bloated code and data duplicated like 4 times. Do less stuff, it's faster.