CPU bound (2) 썸네일형 리스트형 CPU Bound(2) - Multi-process CPU 연산 - 멀티 프로세스 from multiprocessing import current_process, Array, freeze_support, Process, Manager import time import os def cpu_bound(number, total_list): process_id = os.getpid() process_name = current_process().name # Process 정보 출력 print(f"Process ID: {process_id}, Process Name: {process_name}") total_list.append(sum(i * i for i in range(number))) def main(): numbers = [3_000_000 + x for x.. CPU Bound(1) - Single process CPU 연산 - 단일 프로세스 import time def cpu_bound(number): return sum(i * i for i in range(number)) def find_sums(numbers): result = [] for number in numbers: result.append(cpu_bound(number)) return result def main(): numbers = [3_000_000 + x for x in range(30)] # 확인 # print(numbers) start_time = time.time() total = find_sums(numbers) print() print(f"Total list : {total}") print(f"Sum : {sum(total)}") .. 이전 1 다음