转自原文VC/MFC中计算程序运行时间 说明,这四种方法也分别代表了类似的实现,在MFC中,所可以从哪些类集合去考虑. 方法一 利用GetTickCount函数(ms) CString str; long t1=GetTickCount();//程序段开始前取得系统运行时间(ms) ......//to do sth long t2=GetTickCount();//程序段结束后取得系统运行时间(ms) str.Format("time:%dms",t2-t1);//前后之差即程序运行
import time def start_sleep(): time.sleep(3) if __name__ == '__main__': #The start time start = time.clock() #A program which will run for 3 seconds start_sleep() #The End time end = time.clock() print("The function run time is : %.0