title: Why is the time a piece of the whole computaion (benchmking_f in this case) takes in parallel so much longer than the one in sequential approach?
body: <p>I am trying to compare sequential computation and parallel computation in Python.</p>
  
  <p>This is the bench mark function.</p>
  
  <pre><code>def benchmking_f(n=0):
      import time
      items = range(int(10**(6+n)))
  
      def f2(x):return x*x
  
      start = time.time()
      sum_squared = 0
      for i in items:
          sum_squared += f2(i)
      return time.time() - start
  </code></pre>
  
  <p>this sequential computation</p>
  
  <pre><code>problem_size = 2
  
  import time
  start = time.time()
  tlist = []
  for i in range(5):
      tlist.append(benchmking_f(problem_size))
  print('for loop took {}s'.format(time.time() - start))
  print('each iterate took')
  print(tlist)
  </code></pre>
  
  <p>took about 70s to finish the job; each iterate took
  [14.209498167037964, 13.92169737815857, 13.949078798294067, 13.94432258605957, 14.004642486572266]</p>
  
  <p>this parallel approach</p>
  
  <pre><code>problem_size = 2
  
  import itertools
  import multiprocessing
  start = time.time()
  pool = multiprocessing.Pool(5)
  tlist = list(pool.map(benchmking_f, itertools.repeat(problem_size, 5)))
  print('pool.map took {}s'.format(time.time() - start))
  print('each iterate took')
  print(tlist)
  </code></pre>
  
  <p>took about 42.45s; each iterate took
  [41.17476940155029, 41.92032074928284, 41.50966739654541, 41.348535776138306, 41.06284761428833]</p>
  
  <h1>question</h1>
  
  <p>A piece of the whole computation (benchmking_f in this case) took about 14s in sequential and 42.45s in parallel</p>
  
  <p>Why is that?</p>
  
  <p><strong>Note:</strong>
  I am not asking the total time. I am asking the time that A piece of the whole computation, which takes on one iteration in for loop, and one process/thread in parallel.</p>
  
  <p>1-iter <code>benchmking_f</code> takes.</p>