06 测试多进程的时间

import time
from multiprocessing import Process

def f1():
    time.sleep(2)
    print('子进程1号')

def f2():
    time.sleep(3)
    print('子进程2号')

if __name__ == '__main__':

    s = time.time()
    p = Process(target=f1,)
    p2 = Process(target=f2,)
    p.start()
    p2.start()
    p.join()
    p2.join()
    e = time.time()
    print(e - s)
    print('主进程结束')

  

posted on 2019-01-14 15:33  =.===  阅读(101)  评论(0编辑  收藏  举报

导航