Running time calculator using python

Running time calculator using python

This program will calculate the running time of any program. Just change your linux command accrdingly. Thats it. It is a simple function in python.

import time
import sys
import os
val1 = time.time()
print val1
filename1 = sys.argv[1]
os.system(‘gcc ‘+filename1)
os.system(‘./a.out’)
val2 = time.time()
print val2
print val2-val1

Try it out.

Leave a Reply

Your email address will not be published.