程序运行时间的计算

程序运行时间的计算

ID:30840003

大小:61.00 KB

页数:13页

时间:2019-01-04

程序运行时间的计算_第1页
程序运行时间的计算_第2页
程序运行时间的计算_第3页
程序运行时间的计算_第4页
程序运行时间的计算_第5页
资源描述:

《程序运行时间的计算》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库

1、程序运行时间的计算ThemethodforcalculatingtherunningtimeoftheprogramIhavetwocollectionstocontributetooneThisisafunctionthatiscommonlyusedinWindowstocomputetherunningtimeoftheprogram;DWORDdwStart=GetTickCount();//runyourprogramcodehereDWORDdwEnd二GetTickCount();Dwend-dwstartisyourprogramruntime,inmillisecondsTh

2、isfunctionisonlyaccurateto55ms,onetickis55ms・#inelude#ineludeUsingnamespaceSTD.Intmain(intargc,char*argv[])DWORDstartandend;Start二GetTickCount();For(int1二0;I<1000;I++)"Youareagoodchild!,z<

3、yGetTickCount(),buttheaccuracyishigherDWORDdwStart二timeGetTime();//runyourprogramcodehereDWORDdwEnd二timeGetTime();Dwend-dwstartisyourprogramruntime,inmillisecondsAlthoughthereturnedvalueunitshouldbems,thelegendisonly10ms・#inelude#include#pragmacomment(lib,^winmm・Lib")Usingnamesp

4、aceSTD.Intmain(intargc,char*argv[]){DWORDstartandend;Start二timeGetTime()For(int1二0;I<100;I++)"Youareagoodchild!,?<

5、standardcfunction.Clock_tclock(void);#includeClock_t二clock();LongSEC二t/CLOCKS_PER_SEC;He'srecordingtheclockcycle,andtheimplementationdoesn,tlookveryprecise,itneedstobetested;4#includeInclude//UsingnamespaceSTD;Intmain(){Time_tbegin,end;Doubleduration;Thebegin二clock()

6、;//here,syourcodeEnd二clock();Duration=double(end一begin)/CLOCKS_PER_SEC;Thecout<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<}5UnixtimeisrelevantandisstandardlibraryThesearein〈time・H〉Thetimegmfunctionsimplyturnsthestructtmstructureintoatime_tstructureanddoesnotusetimezoneinformation.Astructtm(tm);MktimeUS

7、EStimezoneinformationAstructtm(tm);ThetimelocalfunctionistheGNUextensionwiththeposixfunctionmktime(struct)(structtm*tm);Thegmtimefunctionsimplyturnsthetime_tstructureintoastructtmstructureanddoesnotus

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。