Python Interpreters Benchmarks
x64 ArchLinux : AMD® Ryzen 7 4700U®

 performance measurements

Each table row shows performance measurements for this program with a particular command-line input value N.

 N  CPU secs Elapsed secs Memory KB Code B ≈ CPU Load
5,000,00017.6435.8715,872448  9% 7% 5% 4% 5% 5% 6% 9%

Read the ↓ make, command line, and program output logs to see how this program was run.

Read  benchmark to see what this program should do.

 notes

  source code

# The Computer Language Benchmarks Game
# http://benchmarksgame.alioth.debian.org/
# Contributed by Antti Kervinen
# Modified by Tupteq
# 2to3

import sys
import _thread

# Set minimum stack size for threads, otherwise the program may fail
# to create such a many threads
_thread.stack_size(32*1024)

def threadfun(number, lock_acquire, next_release):
    global n
    while 1:
        lock_acquire()
        if n > 0:
            n -= 1
            next_release()
        else:
            print(number)
            main_lock.release()

# main
n = int(sys.argv[1])
main_lock = _thread.allocate_lock()
main_lock.acquire()

first_lock = _thread.allocate_lock()
next_lock = first_lock

for number in range(503):
    lock = next_lock
    lock.acquire()
    next_lock = _thread.allocate_lock() if number < 502 else first_lock
    _thread.start_new_thread(threadfun,
        (number+1, lock.acquire, next_lock.release))

first_lock.release()
main_lock.acquire()

 make, command-line, and program output logs

 Sun, 23 Apr 2023 09:41:57 GMT

MAKE:
make[1]: Vstupuje se do adresáře „/home/dundee/work/pybenchmarks/bencher/tmp/threadring/tmp“
nuitka3 --remove-output threadring.nuitka-2.nuitka
Nuitka-Options:INFO: Used command line options: --remove-output threadring.nuitka-2.nuitka
Nuitka-Options:WARNING: You did not specify to follow or include anything but main program. Check options and make sure that is intended.
Nuitka:INFO: Starting Python compilation with Nuitka '1.5' on Python '3.10' commercial grade 'not installed'.
Nuitka:INFO: Completed Python level compilation and optimization.
Nuitka:INFO: Generating source code for C backend compiler.
Nuitka:INFO: Running data composer tool for optimal constant value handling.
Nuitka:INFO: Running C compilation via Scons.
Nuitka-Scons:INFO: Backend C compiler: gcc (gcc).
Nuitka-Scons:INFO: Backend linking program with 7 files (no progress information available).
Nuitka-Scons:WARNING: You are not using ccache.
Nuitka:INFO: Removing build directory 'threadring.nuitka-2.nuitka.build'.
Nuitka:INFO: Successfully created 'threadring.nuitka-2.nuitka.bin'.
cp threadring.nuitka-2.nuitka.bin threadring.nuitka-2.nuitka_run
make[1]: Opouští se adresář „/home/dundee/work/pybenchmarks/bencher/tmp/threadring/tmp“
14.36s to complete and log all make actions

COMMAND LINE:
 ./threadring.nuitka-2.nuitka_run 5000000

PROGRAM OUTPUT:
181

Revised BSD license

  Home   Conclusions   License   Play