[Mono-list] FileStream performance under Windows

studan stu_dan at hispeed.ch
Thu Nov 15 14:07:21 UTC 2012


HiI've processed a XML file with XMLDocument("filename") under Windows 7.
After several seconds an error (Fatal error in gc: To many heap sections)
occured. The XML file size is ~130MB.So I changed the code to use
XMLReader("filename") and counted the elments (5448 elements named
"Artikel").The whole operation was done in ~6 sec. With MS.NET instead of
Mono the operation was done in ~1.3 sec. As I started the program (with
MS.NET) after a reboot, the operation was done in ~4.8sec. But with the next
execution of the program the execution time was again at ~1.35 sec.After
some web search I found the FileOptions (0x20000000 //
FILE_FLAG_NO_BUFFERING). Using this option for a FileStream the execution
time under MS.NET is now ~5 sec. I've tested other options but they have no
effect for Mono.Code:        private static int ProcessXMLReader(string
filePath, bool useCache)        {            var articles = 0;           
var options = FileOptions.None;            if (useCache == false)               
options = (FileOptions)0x20000000; // FILE_FLAG_NO_BUFFERING           
using (var fStream = new FileStream(filePath, FileMode.Open,
FileAccess.Read, FileShare.None, 512, options))            {               
var reader = XmlReader.Create(fStream);                while (!reader.EOF)               
{                    if (reader.Read())                    {                       
if (reader.NodeType == XmlNodeType.Element && reader.LocalName == "Artikel")                       
{                            articles++;                        }                   
}                }            }            return articles;        }



--
View this message in context: http://mono.1490590.n4.nabble.com/FileStream-performance-under-Windows-tp4657397.html
Sent from the Mono - General mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-list/attachments/20121115/6693535e/attachment.html>


More information about the Mono-list mailing list