[Python] Python - stress test all 24 CPU cores

Discussão em 'Python' iniciado por Stack, Abril 22, 2025.

  1. Stack

    Stack Membro Participativo

    I want to understand better how to work with multiprocessing in Python and as a test I wanted to set all cores in the CPU at 100%. First I tested it with a CPU that has 8 cores and all cores went to 100%, so that worked. Then I tested it with a CPU that has 24 cores, but for some reason it only sets 8 cores to 100% and I don't know why. There might be a system limitation or there is a limitation on the amount of parrallel processes, but I have no idea what it is exactly and how I can work around it.

    System information:

    • PC 1: i7-9700F, 8 cores, Windows 11 Home version 24H2
    • PC 2: i7-12850HX, 24 cores, Windows 10 Enterprise version 22H2

    Is there a way to work around the limitations and set 16 or all 24 cores to 100%?

    Code:

    import multiprocessing
    import time

    def get_cpu_core_count():
    return multiprocessing.cpu_count()

    def stress_core():
    while True:
    pass

    if __name__ == '__main__':
    num_cores = int(input("Enter the number of CPU cores to stress: "))
    processes = []

    for _ in range(num_cores):
    p = multiprocessing.Process(target=stress_core)
    p.start()
    processes.append(p)

    try:
    while True:
    time.sleep(1)
    except KeyboardInterrupt:
    for p in processes:
    p.terminate()
    p.join()


    EDIT: image of the 24 cores with only 8 at 100% [​IMG]

    [​IMG]

    Continue reading...

Compartilhe esta Página