久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    <tfoot id='y0tMH'></tfoot>
  • <legend id='y0tMH'><style id='y0tMH'><dir id='y0tMH'><q id='y0tMH'></q></dir></style></legend>
      <bdo id='y0tMH'></bdo><ul id='y0tMH'></ul>

    <small id='y0tMH'></small><noframes id='y0tMH'>

    1. <i id='y0tMH'><tr id='y0tMH'><dt id='y0tMH'><q id='y0tMH'><span id='y0tMH'><b id='y0tMH'><form id='y0tMH'><ins id='y0tMH'></ins><ul id='y0tMH'></ul><sub id='y0tMH'></sub></form><legend id='y0tMH'></legend><bdo id='y0tMH'><pre id='y0tMH'><center id='y0tMH'></center></pre></bdo></b><th id='y0tMH'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='y0tMH'><tfoot id='y0tMH'></tfoot><dl id='y0tMH'><fieldset id='y0tMH'></fieldset></dl></div>

        python multiprocessing vs threading for cpu bound work on win

        python multiprocessing vs threading for cpu bound work on windows and linux(python multiprocessing vs threading for cpu bound work on windows and linux)
        <legend id='vu2fF'><style id='vu2fF'><dir id='vu2fF'><q id='vu2fF'></q></dir></style></legend>
            <tbody id='vu2fF'></tbody>

          <i id='vu2fF'><tr id='vu2fF'><dt id='vu2fF'><q id='vu2fF'><span id='vu2fF'><b id='vu2fF'><form id='vu2fF'><ins id='vu2fF'></ins><ul id='vu2fF'></ul><sub id='vu2fF'></sub></form><legend id='vu2fF'></legend><bdo id='vu2fF'><pre id='vu2fF'><center id='vu2fF'></center></pre></bdo></b><th id='vu2fF'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='vu2fF'><tfoot id='vu2fF'></tfoot><dl id='vu2fF'><fieldset id='vu2fF'></fieldset></dl></div>
          <tfoot id='vu2fF'></tfoot>
            • <bdo id='vu2fF'></bdo><ul id='vu2fF'></ul>
              • <small id='vu2fF'></small><noframes id='vu2fF'>

                  本文介紹了python multiprocessing vs threading for cpu bound work on windows and linux的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  所以我敲了一些測試代碼,看看多處理模塊在 cpu 綁定工作上與線程相比如何擴展.在 linux 上,我得到了預期的性能提升:

                  So I knocked up some test code to see how the multiprocessing module would scale on cpu bound work compared to threading. On linux I get the performance increase that I'd expect:

                  linux (dual quad core xeon):
                  serialrun took 1192.319 ms
                  parallelrun took 346.727 ms
                  threadedrun took 2108.172 ms
                  

                  我的雙核 macbook pro 顯示相同的行為:

                  My dual core macbook pro shows the same behavior:

                  osx (dual core macbook pro)
                  serialrun took 2026.995 ms
                  parallelrun took 1288.723 ms
                  threadedrun took 5314.822 ms
                  

                  然后我在一臺windows機器上試了一下,得到了一些非常不同的結果.

                  I then went and tried it on a windows machine and got some very different results.

                  windows (i7 920):
                  serialrun took 1043.000 ms
                  parallelrun took 3237.000 ms
                  threadedrun took 2343.000 ms

                  為什么,為什么,Windows 上的多處理方法這么慢?

                  Why oh why, is the multiprocessing approach so much slower on windows?

                  這是測試代碼:

                  #!/usr/bin/env python
                  
                  import multiprocessing
                  import threading
                  import time
                  
                  def print_timing(func):
                      def wrapper(*arg):
                          t1 = time.time()
                          res = func(*arg)
                          t2 = time.time()
                          print '%s took %0.3f ms' % (func.func_name, (t2-t1)*1000.0)
                          return res
                      return wrapper
                  
                  
                  def counter():
                      for i in xrange(1000000):
                          pass
                  
                  @print_timing
                  def serialrun(x):
                      for i in xrange(x):
                          counter()
                  
                  @print_timing
                  def parallelrun(x):
                      proclist = []
                      for i in xrange(x):
                          p = multiprocessing.Process(target=counter)
                          proclist.append(p)
                          p.start()
                  
                      for i in proclist:
                          i.join()
                  
                  @print_timing
                  def threadedrun(x):
                      threadlist = []
                      for i in xrange(x):
                          t = threading.Thread(target=counter)
                          threadlist.append(t)
                          t.start()
                  
                      for i in threadlist:
                          i.join()
                  
                  def main():
                      serialrun(50)
                      parallelrun(50)
                      threadedrun(50)
                  
                  if __name__ == '__main__':
                      main()

                  推薦答案

                  進程在 UNIX 變體下更加輕量級.Windows 進程很繁重,需要更多時間才能啟動.線程是在 Windows 上進行多處理的推薦方式.

                  Processes are much more lightweight under UNIX variants. Windows processes are heavy and take much more time to start up. Threads are the recommended way of doing multiprocessing on windows.

                  這篇關于python multiprocessing vs threading for cpu bound work on windows and linux的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  What exactly is Python multiprocessing Module#39;s .join() Method Doing?(Python 多處理模塊的 .join() 方法到底在做什么?)
                  Passing multiple parameters to pool.map() function in Python(在 Python 中將多個參數傳遞給 pool.map() 函數)
                  multiprocessing.pool.MaybeEncodingError: #39;TypeError(quot;cannot serialize #39;_io.BufferedReader#39; objectquot;,)#39;(multiprocessing.pool.MaybeEncodingError: TypeError(cannot serialize _io.BufferedReader object,)) - IT屋-程序員軟件開
                  Python Multiprocess Pool. How to exit the script when one of the worker process determines no more work needs to be done?(Python 多進程池.當其中一個工作進程確定不再需要完成工作時,如何退出腳本?) - IT屋-程序員
                  How do you pass a Queue reference to a function managed by pool.map_async()?(如何將隊列引用傳遞給 pool.map_async() 管理的函數?)
                  yet another confusion with multiprocessing error, #39;module#39; object has no attribute #39;f#39;(與多處理錯誤的另一個混淆,“模塊對象沒有屬性“f)
                  <legend id='BXb1N'><style id='BXb1N'><dir id='BXb1N'><q id='BXb1N'></q></dir></style></legend>
                    <tbody id='BXb1N'></tbody>
                  <i id='BXb1N'><tr id='BXb1N'><dt id='BXb1N'><q id='BXb1N'><span id='BXb1N'><b id='BXb1N'><form id='BXb1N'><ins id='BXb1N'></ins><ul id='BXb1N'></ul><sub id='BXb1N'></sub></form><legend id='BXb1N'></legend><bdo id='BXb1N'><pre id='BXb1N'><center id='BXb1N'></center></pre></bdo></b><th id='BXb1N'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='BXb1N'><tfoot id='BXb1N'></tfoot><dl id='BXb1N'><fieldset id='BXb1N'></fieldset></dl></div>
                  • <small id='BXb1N'></small><noframes id='BXb1N'>

                          <bdo id='BXb1N'></bdo><ul id='BXb1N'></ul>
                            <tfoot id='BXb1N'></tfoot>

                            主站蜘蛛池模板: 在线视频 中文字幕 | 日韩精品区 | 欧美精品一区二区三区蜜臀 | 欧美日韩精品免费观看 | 国产成人福利视频在线观看 | 在线看av网址 | 亚洲视频区| 国产精品午夜电影 | 午夜精品福利视频 | 亚洲国产精品人人爽夜夜爽 | 国产成人精品久久二区二区91 | 午夜性色a√在线视频观看9 | 国产精品久久久久久久久免费高清 | 亚洲欧美在线免费观看 | 国产精品国产三级国产aⅴ中文 | 欧美视频福利 | 精品一区二区三区91 | 国产一区91精品张津瑜 | 国产二区视频 | 五月婷婷婷 | 欧美一区成人 | 中文字幕av在线播放 | 少妇无套高潮一二三区 | 好好的日在线视频 | 天天插天天舔 | 一级片在线观看 | 国产91久久久久久久免费 | 国产高清毛片 | 99热播放 | 成人免费网视频 | 在线亚洲电影 | 久久精品亚洲欧美日韩久久 | 美女天天干 | 国产精品久久久爽爽爽麻豆色哟哟 | 国产成人短视频在线观看 | 91国在线 | 99精品网站| 天天操天天干天天透 | 国产精品国产三级国产aⅴ入口 | 国产一区二区在线播放 | 超黄视频网站 |