成免费的crm,久久国产精品新农夫导航新妓网,恋夜秀场全部视频安卓手机,女校花强奷在线播放A级

ASP程序代碼執(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    '小數(shù)點后位數(shù)
    ccstrevent = ""
    ccstrtime = ""
    ccstrformatinterval = "
" & 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 = "
" & 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)計自上一次調(diào)用record方法至現(xiàn)在的時間(第一次調(diào)用時統(tǒng)計聲明類時至調(diào)用時時間),最后在statistic中輸出

類函數(shù):(即時返回信息)
1.nonce
輸出自上一次調(diào)用nonce函數(shù)至現(xiàn)在的時間(第一次調(diào)用時統(tǒng)計聲明類時至調(diào)用時時間)
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
相關文章