from timeit import timeit
reps = 500
stdout = open('add_numbers_outputs.log', 'w')
stderr = open('add_numbers_errors.log', 'w')
external_command = './add_numbers'
parameter = str(1000000)
call_arguments = (
    """[
        '%s',
        '%s'], 
        stdout=stdout,
        stderr=stderr
"""
     % (external_command, parameter))
print('Timing external command ' + external_command + ' with parameter ' + parameter)
time_taken = timeit(stmt='subprocess.call(%s)' % call_arguments, setup=
    """import subprocess;
stdout = open("add_numbers_outputs.log", 'w');
stderr = open("add_numbers_errors.log", 'w')
"""
    , number=reps) / reps
print('Average time taken for %s repetitions: %f seconds' % (reps, time_taken))
get how much time python subprocess spends