Time an external program whose output is being processed by Python
问题 I want to measure the time of execution of an external program whose output is used by my Python script. Calling extprogram the program that produced the output, at the moment I do something like: import time import subprocess def process_output(line): ... ... return processed_data all_processed_data = [] ts = time.time() p = subprocess.Popen("extprogram", stdout=subprocess.PIPE) for line in p.stdout: all_processed_data.append(process_output(line)) te = time.time() elapsed_time = te - ts This