一区二区三区在线-一区二区三区亚洲视频-一区二区三区亚洲-一区二区三区午夜-一区二区三区四区在线视频-一区二区三区四区在线免费观看

服務器之家:專注于服務器技術及軟件下載分享
分類導航

PHP教程|ASP.NET教程|Java教程|ASP教程|編程技術|正則表達式|C/C++|IOS|C#|Swift|Android|VB|R語言|JavaScript|易語言|vb.net|

服務器之家 - 編程語言 - ASP教程 - 實現(xiàn)ASP程序執(zhí)行時間統(tǒng)計類的代碼

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

2019-10-16 10:12asp代碼網 ASP教程

第一次寫ASP類,實現(xiàn)功能:分段統(tǒng)計程序執(zhí)行時間,輸出統(tǒng)計表等.

第一次寫ASP類,實現(xiàn)功能:分段統(tǒng)計程序執(zhí)行時間,輸出統(tǒng)計表等. 

復制代碼代碼如下:


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

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

  Private Sub Class_Initialize  
    ccStrInterval = "|"  '默認分隔符  
    ccIntDecimal = 4    '小數點后位數  
    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 
輸出時是否帶HTML換行標簽 
-html:輸出HTML換行標簽和文本換行符(默認) 
-text:僅輸出文本換行符 

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

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

實例代碼: 

復制代碼代碼如下:


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 

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 久久久亚洲国产精品主播 | 男人的天堂在线观看入口 | 午夜影院网页 | 国产一级特黄aa大片在线 | 无码人妻视频又大又粗欧美 | 超级碰碰青草免费视频92 | 精品国产美女AV久久久久 | 草草线在成年免费视频网站 | 亚洲色图.com | 高h细节肉爽文办公室 | 午夜伦理:伦理片 | 亚洲AV中文字幕无码久久 | bl文全肉高h湿被灌尿 | 免费一级夫妻a | 成年人在线视频观看 | hezyo加勒比一区二区三区 | 国产一级特黄aa大片免费 | 国产chinese男男gaygay | 69欧美性猛交 | tobu8在线观看免费高清 | 免费高清资源黄网站在线观看 | 91影视永久福利免费观看 | 亚洲成av人在线视 | 91在线视频免费观看 | 久久久影院亚洲精品 | 亚洲经典激情春色另类 | 蜜桃成熟时1997在线看免费看 | 国产露脸对白刺激3p在线 | 操乳 | 国产精品福利一区二区亚瑟 | 娜娜啪| 亚洲老头老太hd | 天堂色 | 九九热视频免费观看 | 婷婷色天使在线视频观看 | 精品国产在天天线在线麻豆 | 91尤物在线播放 | 热99精品视频 | 国产精品麻豆99久久 | 扒开女人下面 | 污网站免费观看在线高清 |