import subprocess import sys import perf # Simulate a Python process which allocated a lot of memory # to see the speedup of vfork when spawing a child process BIG_ALLOC = b'x' * (2 * 1024 * 1024 * 1024) # 2 GiB # Program with very short execution time and very small memory footprint ARGS = ["/usr/bin/pwd"] def func(): subprocess.run(ARGS, close_fds=False, stdout=subprocess.PIPE) runner = perf.Runner() runner.bench_func('func', func)