亚洲欧洲国产欧美一区精品,激情五月亚洲色五月,最新精品国偷自产在线婷婷,欧美婷婷丁香五月天社区

      考試首頁 | 考試用書 | 培訓(xùn)課程 | 模擬考場(chǎng) | 考試論壇  
        當(dāng)前位置:編程開發(fā) > DotNET > Delphi.Net > 文章內(nèi)容
        

      Delphi基礎(chǔ)教程:Delphi高精度計(jì)時(shí)方法

       [ 2017年9月16日 ] 【

        //取毫秒級(jí)時(shí)間精度(方法一):

        var

        t1,t2:int64;

        r1:int64;

        begin

        t1:=GetTickCount;//獲取開始計(jì)數(shù) WINDOWS API

        sleep(1000);{do...}//執(zhí)行要計(jì)時(shí)的代碼

        t2:=GetTickCount;//獲取結(jié)束計(jì)數(shù)值

        r1:=t2-t1;//取得計(jì)時(shí)時(shí)間,Y\`國4~絡(luò)(}.u_%t"hV單位毫秒(ms)

        showmessage(inttostr(r1));

        end;

        //取毫秒級(jí)時(shí)間精度(方法二):

        //use DateUtils;//引用DateUtils單位

        var

        t1,t2:tdatetime;

        r1:int64;

        begin

        t1:=now();//獲取開始計(jì)時(shí)時(shí)間

        sleep(1000);{do...}//執(zhí)行要計(jì)時(shí)的代碼

        t2:=now();//獲取結(jié)束計(jì)時(shí)時(shí)間

        r1:=SecondsBetween(t2,t1);//取得計(jì)時(shí)時(shí)間,D6k=+W的TsoUbP育_II單位秒(s)

        r1:=MilliSecondsBetween(t2,t1);//取得計(jì)時(shí)時(shí)間,

        fTVGgU8E36

        單位毫秒(ms)

        showmessage(inttostr(r1));

        end;

        //注:以上兩種方式經(jīng)本人測(cè)試好像只能產(chǎn)生0.01秒的計(jì)時(shí)精度

        //取系統(tǒng)級(jí)時(shí)間精度:

        var

        c1:int64;

        t1,t2:int64;

        r1:double;

        begin

        QueryPerformanceFrequency(c1);//WINDOWS API   返回計(jì)數(shù)頻率(Intel86:1193180)(獲得系統(tǒng)的高性能頻率計(jì)數(shù)器在一毫秒內(nèi)的震動(dòng)次數(shù))

        QueryPerformanceCounter(t1);//WINDOWS API 獲取開始計(jì)數(shù)值

        sleep(1000);{do...}//執(zhí)行要計(jì)時(shí)的代碼

        QueryPerformanceCounter(t2);//獲取結(jié)束計(jì)數(shù)值

        r1:=(t2-t1)/c1;//取得計(jì)時(shí)時(shí)間,

        L`:(Y\O件}\^k(育*軟{Ux

        j5^國GZ,)中1a6t."1)Ti

        x@\t)ac提W教

        YjTt]$1UCqS'E)網(wǎng)7g單位秒(s)

        r1:=(t2-t1)/c1*1000;//取得計(jì)時(shí)時(shí)間,單位毫秒(ms)

        r1:=(t2-t1)/c1*1000000;//取得計(jì)時(shí)時(shí)間,單位微秒

        showmessage(floattostr(r1));

        end;

      將考試網(wǎng)添加到收藏夾 | 每次上網(wǎng)自動(dòng)訪問考試網(wǎng) | 復(fù)制本頁地址,傳給QQ/MSN上的好友 | 申請(qǐng)鏈接 | 意見留言 TOP
      關(guān)于本站  網(wǎng)站聲明  廣告服務(wù)  聯(lián)系方式  站內(nèi)導(dǎo)航  考試論壇
      Copyright © 2007-2013 中華考試網(wǎng)(Examw.com) All Rights Reserved