I have to write the time it takes for several C programs to run on several files using:
time ./program filename
to a spread sheet and am using subprocess.check_output
to get the stdout
as a string. I should get something along the lines of:
real 0m0.001s
user 0m0.001s
sys 0m0.000s
but I get:
b'0.00user 0.00system 0:00.00elapsed ?%CPU (0avgtext+0avgdata
1388maxresident)k\n0inputs+0outputs (0major+60minor)pagefaults
0swaps\n'
I see the user and system time but they get cut off after two decimal places. Is there a way to make sure the output reads all 3 decimal places? Here is my code:
import xlwt
import subprocess
files = ('100KB.txt', '1MB.txt', '10MB.txt', '100MB.txt')
programs = ('./10kBuffer', './step2', './step3', './step4')
command = ['time', programs[0], files[0]]
out = subprocess.check_output(command, stderr=subprocess.STDOUT)
print(out)