Is it possible to use threads to speed up file reading?

后端 未结 6 1095
情话喂你
情话喂你 2020-12-05 07:47

I want to read a file as fast as possible (40k lines) [Edit : the rest is obsolete].

Edit: Andres Jaan Tack suggested a solution based on one thread per file, and I

6条回答
  •  甜味超标
    2020-12-05 08:44

    This is a problem of granularity. You've got a small file, and very little processing to do. One thread can probably gobble the entire file in one time slice and process it in the next. Two threads would be worse than one. You need a much larger task before considering parallelism as a performance solution.

提交回复
热议问题