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

ASP程序代碼執(zhí)行時(shí)間統(tǒng)計(jì)類(lèi)

熱門(mén)標(biāo)簽:鳳臺(tái)百度地圖標(biāo)注店 修改地圖標(biāo)注 外呼系統(tǒng)API接口 金昌電話機(jī)器人價(jià)格 武夷山旅游地圖標(biāo)注 縣域地圖標(biāo)注打印店 怎么在地圖標(biāo)注自己 萊西電子地圖標(biāo)注 個(gè)人可以辦理400電話么
第一次寫(xiě)ASP類(lèi),實(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ì)類(lèi)

  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

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

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

類(lèi)函數(shù):(即時(shí)返回信息)
1.Nonce
輸出自上一次調(diào)用nonce函數(shù)至現(xiàn)在的時(shí)間(第一次調(diào)用時(shí)統(tǒng)計(jì)聲明類(lèi)時(shí)至調(diào)用時(shí)時(shí)間)
2.Total
輸出聲明類(lèi)到現(xiàn)在總時(shí)間
3.Statistic
輸出所有Record統(tǒng)計(jì)信息和總程序時(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("開(kāi)方")
Response.Write objRecord.Statistic

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

標(biāo)簽:涼山 邢臺(tái) 南京 清遠(yuǎn) 通遼 赤峰 上海 楚雄

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《ASP程序代碼執(zhí)行時(shí)間統(tǒng)計(jì)類(lèi)》,本文關(guān)鍵詞  ASP,程序,代碼,執(zhí)行,時(shí)間,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《ASP程序代碼執(zhí)行時(shí)間統(tǒng)計(jì)類(lèi)》相關(guān)的同類(lèi)信息!
  • 本頁(yè)收集關(guān)于ASP程序代碼執(zhí)行時(shí)間統(tǒng)計(jì)類(lèi)的相關(guān)信息資訊供網(wǎng)民參考!
  • 企业400电话

    智能AI客服机器人
    15000

    在线订购

    合计11份范本:公司章程+合伙协议+出资协议+合作协议+股权转让协议+增资扩股协议+股权激励+股东会决议+董事会决议

    推薦文章