开发者

Reading a Large text file or reading 2 identical divided text file faster, when thread is taken into account

开发者 https://www.devze.com 2023-02-04 04:19 出处:网络
Just a question regarding about file reading in threading. To read a 10MB text file, or read two 5Mb each files which is identical to the 10Mb one, which is faster? Let say the processing unit consis

Just a question regarding about file reading in threading.

To read a 10MB text file, or read two 5Mb each files which is identical to the 10Mb one, which is faster? Let say the processing unit consist multithre开发者_C百科ading.


If you read the file from disk I would guess that the non-threaded, single 10MB file approach will be faster, since you would otherwise have two threads competing to use the same shared resource, which in this case also is likely to be the slowest part in the chain. This could perhaps change if you keep the two files on different physical disks.

The best way to find out is to write code for both approaches and measure their performence in the kind of setup where it is intended to run.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号