from multiprocessing import Process, current_process
import time

def cpu_bound_task(n):
    total = 0
    for i in range(n):
        total += i
    print(f"Process {current_process().name} finished calculation with total = {total}")

# Create and start multiple processes
n = 10**7
processes = [Process(target=cpu_bound_task, args=(n,)) for _ in range(4)]

start_time = time.time()

for process in processes:
    process.start()
for process in processes:
    process.join()

print("Total time with multiprocessing:", time.time() - start_time)
