I tried to see the effect of time lapses. And how can it consume a significant amount of time. In fact, I tried to divide a certain work by the number of threads and see the effect.
I have a dual core processor. Thus, two threads can work in parallel. I tried to check if I have w work that is performed by two threads, and if I have the same work as t-threads, with every thread doing w / t work. How long does it take?
Since slicing time is a time consuming process, I expected that when I do the same work using a process with two threads or using a t-thread process, the time taken by the t-thread process will be longer
However, I found that this is not the case. I tried with t = 10. And yet it is faster than a process with two threads. E.g. if I need to do 10,000,000 iterations, then with two thread processes, I will have 2 threads, iterations per 5,000,000, so we have a total of 10,000,000 iterations. If I am connected to a process with 10 threads, I will give each thread an iteration of 1,000,000 so that we have a total of 10,000,000.
I expected a process with 10 threads to take longer. But this is not so. Is there a mistake in the code? I'm fine.
Any suggestions?
source
share