如何提高性能?将数据写入文本文件时 [英] How to increse the performance ? While Writting data into text file
问题描述
我有一个Sql Table,其中有两列Rowid – int,XMLRecord – XML其中包含1000000条记录.我必须阅读该记录&将其写入文本文件.
我已经编写了程序来做到这一点,但要花大约25分钟的时间才能提高该过程的性能
我有这样的方法
Hi,
I have one Sql Table which is having two columns Rowid – int, XMLRecord – XML which contains 1000000 records in it. I have to read that record & write that in to text file.
I have written program to do that but it is taking near about 25minute to do that how can I increase the performance of this process
I have methods like this
ReadXML()
{
Sql XML to get data from Sql table
XMLReader to read node of xml
This is returning Entity object
}
WriteXML (Entity object)
{
Here I am using some more variable & objects
I am using some looping to get data from Entity object
StreamWritter to write into file
}
在这种情况下,ReadXML()方法仅花费3分钟,而WriteXML(实体对象)花费更多时间.
如何提高该程序的性能?使用循环,StreamWritter时应注意些什么,在循环中我创建一些本地对象时有必要销毁该对象.哪种方法最适合处理这些对象?
请帮助我....
-Dattatrya Moin
In this case ReadXML () method is taking only 3 minutes and WriteXML (Entity object) is taking more time.
How can I increase performance of this program? Which care should I take while using loop, StreamWritter and in loop I am creating some local object it is necessary to destroy that . Which method should be the best to dispose those objects?
Please assist me….
-Dattatrya Moin
推荐答案
在并行循环中查看以下链接.
http://msdn.microsoft.com/en-us/library/dd460720.aspx [ ^ ]
还有异步编程.
http://msdn.microsoft.com/en-us/library/2e08f6yc%28v = vs.71%29.aspx [ ^ ]
Take a look at the following link below on parallel loops.
http://msdn.microsoft.com/en-us/library/dd460720.aspx[^]
And async programming.
http://msdn.microsoft.com/en-us/library/2e08f6yc%28v=vs.71%29.aspx[^]
使用后台线程来执行长期运行的过程.
Use a background thread to do the long running process.
这篇关于如何提高性能?将数据写入文本文件时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!