写入txt文件的速度(许多文件或单个文件) [英] speed to writing to a txt file (many files or one single file)

查看:188
本文介绍了写入txt文件的速度(许多文件或单个文件)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不确定将这个放在哪个论坛上。我使用VB.net,所以我发布在这里。



我有很多数据,我通过VB.net创建,然后我必须将所有数据写入一个txt文件。我可以选择写入多个文件(500-1000个文件),或者我可以写入单个文件。我的问题是哪种方式是最快的方式(写入硬盘的时间)?



以防万一需要额外的信息。每个文件将包含大约20-40行数据。每行约有20-30个字符。



提前谢谢,



-J

I was not sure which forum to put this. I use VB.net so i posted here.

I have a lot of data that i am creating via VB.net and then i have to write all that data to a txt file. I have an option to write to several files (500-1000 files), or i can write to a single file. My question is which way would be the fastest way (time to write to hard drive)?

Just in case additional info in needed for the answer. Each file will have about 20-40 lines of data. Each line will have about 20-30 characters.

Thank you in advance,

-J

推荐答案

这取决于很多因素,你的内容和处理,所以很难给出一个单一的食谱。一般来说,大块写入更好,但由于文件流缓冲,它的效果并不那么简单。你的计算也可能成为瓶颈。我只是通过计时不同的场景来获得一些练习,然后你可以快速发展它的意义。只有一种食谱是通用的:避免做一些愚蠢的事情。 :-)



-SA
It really depends on many factors, your content and its processing, so it's hard to give one single recipe. Generally speaking, writing in big chunks is better, but the effect of it is not so straightforward, because of file stream buffering. You calculations can also become a bottleneck. I would just gain some practice by timing different scenarios, then you can quickly develop the sense of it. Only one recipe is universal: avoid doing something stupid. :-)

—SA


这篇关于写入txt文件的速度(许多文件或单个文件)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆