import subprocess, sys from time import time RUNS = 5 LOOPS = 100 ARGS = [sys.executable, '-c', 'pass'] def bench(): best = None for run in range(RUNS): print("%s/%s" % (1+run, RUNS)) a = time() for loop in range(LOOPS): subprocess.call(ARGS) b = time() dt = float(b - a) / LOOPS if best is not None: best = min(best, dt) else: best = dt return best t = bench() print("Best startup: %.1f ms" % (t * 1000.))