Each table row shows performance measurements for this RustPython program with a particular command-line input value N.
| N | CPU secs | Elapsed secs | Memory KB | Code B | ≈ CPU Load |
|---|---|---|---|---|---|
| 5,000,000 | 5.16 | 5.20 | 15,540 | 406 | 97% 4% 2% 1% 6% 3% 3% 3% |
Read the ↓ make, command line, and program output logs to see how this program was run.
Read thread-ring benchmark to see what this program should do.
# The Computer Language Benchmarks Game
# http://benchmarksgame.alioth.debian.org/
#
# contributed by Daniel Nanz 2008-03-11
# Coroutines via enhanced generators
# 2to3
import sys
import itertools
def main(n = int(sys.argv[1]), n_threads=503, cycle=itertools.cycle):
def worker(worker_id):
n = 1
while True:
if n > 0:
n = (yield (n - 1))
else:
print(worker_id)
return
threadRing = [worker(w) for w in range(1, n_threads + 1)]
for t in threadRing: foo = next(t) # start exec. gen. funcs
sendFuncRing = [t.send for t in threadRing] # speed...
for send in cycle(sendFuncRing):
try:
n = send(n)
except StopIteration:
break
main()
Sun, 30 Jul 2023 11:18:24 GMT COMMAND LINE: /usr/bin/rustpython threadring.rustpython 5000000 PROGRAM OUTPUT: 181 encodings initialization failed. Only utf-8 encoding will be supported. ModuleNotFoundError: No module named 'encodings' The above exception was the direct cause of the following exception: RuntimeError: Could not import encodings. Is your RUSTPYTHONPATH set? If you don't have access to a consistent external environment (e.g. if you're embedding rustpython in another application), try enabling the freeze-stdlib feature