CPU Parameters:
1 Physical cpu,2 logical CPUs (Hyper-threading), single-core specific http://blog.csdn.net/dba_waterbin/article/details/8644626 physical CPU, logical CPU, and CPU cores
Package files, single process
#Coding=utf-8 fromMultiprocessingImportProcessImportsys, OSImport TimedefTimetask (times): cmd="Tar zcfph/data/nerri_%s.tar.gz/data/backup"%Times Os.system (cmd)defworks_multi_process (func, Worknum): Proc_record= [] forIinchRange (worknum): P= Process (target = func, args =(i,)) P.start () Proc_record.append (p) forPinchProc_record:p.join ()defworks_single_process (func, Worknum): Proc_record= [] forIinchRange (worknum): P= Process (target = func, args =(i,)) P.start () P.join ( )if __name__=='__main__': PrintTime.strftime ('============start:%h%m%s==========') procs= 2works_multi_process (Timetask, procs)PrintTime.strftime ('============end:%h%m%s========')
Results of Transport:
Single process:
============start:154554==========
============end:154903===========
Multi-process:
============start:155513==========
============end:155627========
viewing disk and CPU utilization: Iostat-x 1 10
Ps:
Single process consumes about 90 CPU average CPU about 45
Number of process processes 2 per process consumes about 90 CPU total CPU around 100
Number of process processes 31 processes Occupy CPU 90 or so the other two processes occupy cpu45 around the total CPU 100 or so
Number of process processes 4 per process consumes around cpu45 total CPU 100
The thread scheduling of the system. Even a single thread, at different time slices, can also be dispatched to different cores. can control which core to run on ~
Python multi-process improves CPU utilization