濮阳杆衣贸易有限公司

主頁(yè) > 知識(shí)庫(kù) > 實(shí)現(xiàn)ASP程序執(zhí)行時(shí)間統(tǒng)計(jì)類的代碼

實(shí)現(xiàn)ASP程序執(zhí)行時(shí)間統(tǒng)計(jì)類的代碼

熱門標(biāo)簽:咸陽(yáng)銷售外呼系統(tǒng) 外呼回?fù)芟到y(tǒng)圖片 常用地圖標(biāo)注范圍點(diǎn) 蘭州智能語音電銷機(jī)器人功能 離線電子地圖標(biāo)注軟件注冊(cè) 寧夏怎么申請(qǐng)400電話 為什么外呼系統(tǒng)需要預(yù)存話費(fèi)呢 企數(shù)外呼系統(tǒng)能用多久 辦理400電話一年多少錢
第一次寫ASP類,實(shí)現(xiàn)功能:分段統(tǒng)計(jì)程序執(zhí)行時(shí)間,輸出統(tǒng)計(jì)表等. 
復(fù)制代碼 代碼如下:

Class ccClsProcessTimeRecorder 
'程序作者:明月星光 
'作者主頁(yè):http://www.5iya.com/blog 
'http://www.kuozhanming.com 
'ASP程序代碼執(zhí)行時(shí)間統(tǒng)計(jì)類 

  Private ccInti,ccIntNonceTime,ccIntDecimal 
  Private ccIntStartTime,ccIntEndTime,ccIntNow,ccIntNonce 
  Private ccStrInterval,ccStrEvent,ccStrTime,ccStrStatisticLog,ccStrFormatInterval 
  Private ccArrEvent,ccArrTime 

  Private Sub Class_Initialize 
    ccStrInterval = "|"  '默認(rèn)分隔符 
    ccIntDecimal = 4    '小數(shù)點(diǎn)后位數(shù) 
    ccStrEvent = "" 
    ccStrTime = "" 
    ccStrFormatInterval = "br />"  vbCrLf 
    ccIntStartTime = Timer 
    ccIntNow = ccIntStartTime 
    ccIntNonce = ccIntStartTime 
  End Sub 

  Public Sub Record(ccStrEventName) 
    ccStrEvent = ccStrEvent  ccStrInterval  Replace(ccStrEventName,ccStrInterval,"") 
    ccStrTime = ccStrTime  ccStrInterval  FormatNumber(Timer-ccIntNow,ccIntDecimal,True,False,True) 
    ccIntNow = Timer 
  End Sub 

  Public Property Let Format(ccStrFormatType) 
    If LCase(Trim(ccStrFormatType)) = "html" Then 
      ccStrFormatInterval = "br />"  vbCrLf 
    Else 
      ccStrFormatInterval = vbCrLf 
    End If 
  End Property 

  Public Function Statistic 
    If InStr(ccStrEvent,ccStrInterval) > 0 Then 
      ccIntEndTime = Timer 
      ccArrEvent = Split(ccStrEvent,ccStrInterval) 
      ccArrTime = Split(ccStrTime,ccStrInterval) 
      ccStrStatisticLog = ccStrStatisticLog  "Process Time Record"  ccStrFormatInterval 
      ccStrStatisticLog = ccStrStatisticLog  "--------------------------------------"  ccStrFormatInterval 
      For ccInti = 1 To UBound(ccArrEvent) 
        ccStrStatisticLog = ccStrStatisticLog  ccArrEvent(ccInti)  " : "  ccArrTime(ccInti)  " s"  ccStrFormatInterval 
      Next 
      ccStrStatisticLog = ccStrStatisticLog  "--------------------------------------"  ccStrFormatInterval 
      ccStrStatisticLog = ccStrStatisticLog  "Total : "  FormatNumber(ccIntEndTime-ccIntStartTime,ccIntDecimal,True,False,True)  " s" 
      Statistic = ccStrStatisticLog 
    Else 
      Statistic = "No Record" 
    End If 
  End Function 

  Public Function Nonce 
    ccIntNonceTime = FormatNumber(Timer-ccIntNonce,ccIntDecimal,True,False,True) 
    ccIntNonce = Timer 
    Nonce = ccIntNonceTime 
  End Function 

  Public Function Total 
    Total = FormatNumber(Timer-ccIntStartTime,ccIntDecimal,True,False,True) 
  End Function 

End Class 


類屬性:
1.Format
輸出時(shí)是否帶HTML換行標(biāo)簽
-html:輸出HTML換行標(biāo)簽和文本換行符(默認(rèn))
-text:僅輸出文本換行符

類方法:
1.Record("Code Name")
統(tǒng)計(jì)自上一次調(diào)用Record方法至現(xiàn)在的時(shí)間(第一次調(diào)用時(shí)統(tǒng)計(jì)聲明類時(shí)至調(diào)用時(shí)時(shí)間),最后在Statistic中輸出

類函數(shù):(即時(shí)返回信息)
1.Nonce
輸出自上一次調(diào)用nonce函數(shù)至現(xiàn)在的時(shí)間(第一次調(diào)用時(shí)統(tǒng)計(jì)聲明類時(shí)至調(diào)用時(shí)時(shí)間)
2.Total
輸出聲明類到現(xiàn)在總時(shí)間
3.Statistic
輸出所有Record統(tǒng)計(jì)信息和總程序時(shí)間

實(shí)例代碼:
復(fù)制代碼 代碼如下:

Dim objRecord,i,k,j,x 

Set objRecord = New ccClsProcessTimeRecorder 
objRecord.Format = "html" 

For i = 1 To 100000 
  x = 2 + 2 
Next 

Call objRecord.Record("加法") 
For j = 1 To 100000 
  x = 2 * 2 
Next 

Call objRecord.Record("乘法") 

For k = 1 To 100000 
  x = 2 ^ 2 
Next 

Call objRecord.Record("開方") 

Response.Write objRecord.Statistic 



輸出:
Process Time Record
--------------------------------------
加法 : 0.0625 s
乘法 : 0.0469 s
開方 : 0.1094 s
--------------------------------------
Total : 0.2188 s
您可能感興趣的文章:
  • ASP程序代碼執(zhí)行時(shí)間統(tǒng)計(jì)類
  • asp.net顯示頁(yè)面執(zhí)行時(shí)間
  • asp.net 通過httpModule計(jì)算頁(yè)面的執(zhí)行時(shí)間
  • asp.net計(jì)算每個(gè)頁(yè)面執(zhí)行時(shí)間的方法
  • ASP顯示頁(yè)面執(zhí)行時(shí)間的方法

標(biāo)簽:鐵嶺 麗江 溫州 家電維修 昆明 昌都 泰州 咸陽(yáng)

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《實(shí)現(xiàn)ASP程序執(zhí)行時(shí)間統(tǒng)計(jì)類的代碼》,本文關(guān)鍵詞  實(shí)現(xiàn),ASP,程序,執(zhí)行,時(shí)間,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《實(shí)現(xiàn)ASP程序執(zhí)行時(shí)間統(tǒng)計(jì)類的代碼》相關(guān)的同類信息!
  • 本頁(yè)收集關(guān)于實(shí)現(xiàn)ASP程序執(zhí)行時(shí)間統(tǒng)計(jì)類的代碼的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    随州市| 旅游| 汉沽区| 湛江市| 五指山市| 磴口县| 邢台市| 金沙县| 宜昌市| 乡宁县| 开平市| 稷山县| 西畴县| 锡林浩特市| 汽车| 乐安县| 合川市| 湾仔区| 娄烦县| 阿鲁科尔沁旗| 香格里拉县| 天台县| 衡阳县| 阳西县| 滕州市| 德保县| 东丰县| 来安县| 滦南县| 伊通| 洛南县| 怀化市| 肥东县| 罗甸县| 嘉祥县| 繁峙县| 天等县| 香河县| 铅山县| 瓮安县| 巴南区|