简体   繁体   中英

Script execution time on different computers (python 3.5, miniconda)

I was faced with the following problem: on a computer (number 2) script execution time is significantly greater than on another computer (computer 1).

  • Computer 1 - i3 - 4170 CPU @ 3.7 GHz (4 core), 4GB RAM (Execution time 9.5 minutes)
  • Computer 2 - i7 - 3.07GHz (8 core), 8GB RAM (Execution time 15-17 minutes)

I use Python to process Excel files. I import for these three libraries:

  • xlrd , xlsxwriter , win32com

Why is the execution time different? How can I fix it?

它运行在单核上,计算机1具有更高的时钟频率=更快的单线程处理。

As explained in a comment, Python uses the Global Interpreter Lock (GIL) . As stated on the Wiki: "An interpreter that uses GIL always allows exactly one thread to execute at a time, even if run on a multi-core processor ".

Your i3 processor may 'only' have 4 cores instead of the 8 cores in your i7, but Python will only use 1 thread at a time: so the faster the core, the faster your script is executed. As explained on this page : "The CPU speed determines how many calculations it can perform in one second of time. The higher the speed, the more calculations it can perform, thus making the computer faster."

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM