处理大数据?
我在我的应用程序中使用 WinForms 和 C#,我的数据主要是一些字符串、整数和许多列表。现在我将它们存储在 xml 和文本文件中,但我刚刚发现读取数据需要太长时间。我正在使用 XmlWriter 和 XmlReader。例如,我有 4 个 xml 文件,总计 2-3 mbs,我解析它们,还有大约 250 个文本,我一次读取它们的内容。加载需要 3-4 分钟,而且我没有使用线程。这是正常现象还是有其他情况?我应该使用其他方式来存储我的数据吗?我必须只使用一个线程吗?
编辑 我发现了问题。这与阅读无关(我认为)。不管怎样,假设我的数据不会超过几MB,我应该使用数据库还是我可以使用xml?
I'm using WinForms and C# for my application and my data is mainly some strings, integers and many lists. Now I store them in xml and text files but I just found out that reading the data takes too long. I'm using XmlWriter and XmlReader. For example I have 4 xml files totalling 2-3 mbs which I parse and ~250 text which I read their contents all at once. The loading takes 3-4 minutes and I'm not using threads. Is this normal or is something else going on? Should I use some other way to store my data? Does it have to do that I only use one thread?
EDIT
I found the problem. It had nothing to do with the reading (I think). Anyway though, assuming the my data won't get more than a couple of MBs, should I use a database or I'm fine with xml?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能主要受 I/O 限制,因此并行化不会有太大帮助 - 但它肯定不会花费 3 到 4 分钟(更像是 3 到 4 秒) - 正在发生其他事情。
如果您有大量结构化数据,您应该考虑使用数据库 - 然后您可以查询所需的数据,而不必一次加载所有内容。即 SQL Server Compact 在桌面中使用时占用空间非常小应用程序。
You are probably mostly I/O bound on this, so parallelizing will not help much - but it certainly should not take 3 to 4 minutes (more like 3 to 4 seconds) - something else is going on.
If you have large structured data, you should consider a database instead - then you can query for the data you need instead of having to load up everything at once. I.e. SQL Server Compact has a very small footprint for use in desktop applications.