Did an experiment on multi-thread processing. The number of items to be processed was 988. I used this simple method of measurement.
- Round one. One thread to process one item
- Round two. One thread to process 2 items
- Round three. One thread to process 4 items
- Round N. One thread to process …
The raw result of the experiment:
|Max Number of Items
in one Thread
|Number of Threads||Seconds|
- When one thread processed all 988 items, it took 135 seconds
- When two threads processed all 988 items, it took 74 seconds.
- When four threads processed all 988 items, it took 42 seconds.
- When number of threads were equal or greater than four threads, the processing time was around 42 seconds.
- It can save a lot of time using multi-thread processing
- It is almost a linear correlation between the time saved and the number of threads increased during early stage.
- Depending upon the context, the plateau is reached sooner or later. After that, it doesn’t matter how many threads you added, the time for processing is constant.