mirkaim
mirkaim

Reputation: 314

Multithreading - Do I need this?

I am just trying to check if implementing multiple threads for this processing task would actually speed up processing time. I'm thinking it won't but want to be sure.

Example: Say I want to read in every byte of a file, and then output each byte to a new file. I don't want to do this but just hear me out.

So if I begin to output each byte serially in a loop to a new file, would it speed up the process if I instead, for example, broke the file into multiple pieces and then read in and wrote out those pieces in different threads?

I am thinking it won't because even though the threads are separated and can run their own serial executions, you're still having to put it through the processor so ultimately, all bytes are executed individually and never actually simultaneously.

Caveat: I am not talking about the differences in machines with multiple cores vs. single cores. I am wondering for each individual computer. If I ran a version that wasn't multithreaded on one machine vs. a version that was multithreaded, would there actually be an increase in speed?

I know I could write a program to do this and test it but want to check first if I am thinking about this the right way.

Thanks.

Upvotes: 0

Views: 58

Answers (1)

ThisHandleNotInUse
ThisHandleNotInUse

Reputation: 1153

It depends on the hardware you're using and what you're processing. If you're doing a lot of harddrive reading and writing than your bottleneck will probably be disk read write operations more than the CPU. If you're doing a lot of processing in RAM, then multithreaded will absolutely speed up your processing on a multi-core machine.

Upvotes: 3

Related Questions