GCD = better performance not regarding the UI?

I have been trying to read up on GCD and trying to figure it out. I read a lot of places, that one should always use GCD, if one is doing some heavy work, which will freeze up the UI, and I do understand that, but could GCD also be used just for performance sake. Say I have a loop that need to run 10 times, each iteration being data heavy. Would it improve performance to run half of these iterations of a different thread, so that two threads are sharing the workload or will it still take the same amount of time to go through the loop?


It would help running two serial gdc queues if your device has two processors. However, the idea is that you shouldn't care, call dispatch_queue_create with DISPATCH_QUEUE_CONCURRENT and let the device figure out what is the optimum number of tasks to run in parallel.

This is entirely to your design of the looping logic, there is not correct answer to your question, since you still need to define how will you join and merge the 2 different processing that you made to this data, where is the data going to be saved, what is the the logical issue you are going to solve

Nevertheless what you are trying to achieve in two threads may lead you to premature optimization, so before you start optimizing your code to do so, please consider if its worth the complication that you are going to introduce to your code or not

Need Your Help

Python: How to end program in a loop?

python while-loop break

The Python program I have made is menu based and requires inputs from the user to navigate around the program.

Faster multiple threading vs single threading

java multithreading performance

I'm implementing an online store where customers drop in an order and my program generates a summary of who the client is and what items they bought.