????(8)????????????????????????????????
????<code class="python">t = time.time()
????ios = []
????t = time.time()
????for x in range(10):
????thread = Thread(target=http_request)
????ios.append(thread)
????thread.start()
????e = ios.__len__()
????while True:
????for th in ios:
????if not th.is_alive():
????e -= 1
????if e <= 0:
????break
????print("Thread Http Request"?? time.time() - t)</code>
????Output: 0.7419998645782471??0.3839998245239258??0.3900001049041748
????(9)??????????????CPU??????????????
????<code class="python">counts = []
????t = time.time()
????for x in range(10):
????process = Process(target=count?? args=(1??1))
????counts.append(process)
????process.start()
????e = counts.__len__()
????while True:
????for th in counts:
????if not th.is_alive():
????e -= 1
????if e <= 0:
????break
????print("Multiprocess cpu"?? time.time() - t)</code>
????Output: 54.342000007629395??53.437999963760376
????(10)??????????????IO????????
????<code class="python">t = time.time()
????ios = []
????t = time.time()
????for x in range(10):
????process = Process(target=io)
????ios.append(process)
????process.start()
????e = ios.__len__()
????while True:
????for th in ios:
????if not th.is_alive():
????e -= 1
????if e <= 0:
????break
????print("Multiprocess IO"?? time.time() - t)</code>
????Output: 12.509000062942505??13.059000015258789
????(11)??????????????Http????????????
????<code class="python">t = time.time()
????httprs = []
????t = time.time()
????for x in range(10):
????process = Process(target=http_request)
????ios.append(process)
????process.start()
????e = httprs.__len__()
????while True:
????for th in httprs:
????if not th.is_alive():
????e -= 1
????if e <= 0:
????break
????print("Multiprocess Http Request"?? time.time() - t)</code>
????Output: 0.5329999923706055??0.4760000705718994
????????? CPU???????? IO???????? ???????????????? ??????? 94.91824996469 22.46199995279 7.3296000004 ???????? 101.1700000762 24.8605000973 0.5053332647 ???????? 53.8899999857 12.7840000391 0.5045000315
????????????????????????????
???????????IO?????????????????к???????????IO????????????????Щ????????????????CPU?????????????????????????????????????????????????????????????????????????????????????????
?????????????????CPU????????IO?????????????????????????????????????????????У????????????????????????????????????????????????????????????????????????CPU??????????????????????£????????????????????