濮阳杆衣贸易有限公司

主頁 > 知識庫 > asp.net計(jì)算每個(gè)頁面執(zhí)行時(shí)間的方法

asp.net計(jì)算每個(gè)頁面執(zhí)行時(shí)間的方法

熱門標(biāo)簽:威海電銷 寧夏機(jī)器人電銷 河南語音外呼系統(tǒng)公司 400免費(fèi)電話怎么辦理 t3出行地圖標(biāo)注怎么做 400電話辦理最優(yōu)質(zhì) 外呼電銷機(jī)器人軟件 河北網(wǎng)絡(luò)回?fù)芡夂粝到y(tǒng) 關(guān)于宗地圖標(biāo)注技術(shù)規(guī)范

本文實(shí)例講述了asp.net計(jì)算每個(gè)頁面執(zhí)行時(shí)間的方法。分享給大家供大家參考。具體分析如下:

這里的asp.net代碼可實(shí)現(xiàn)計(jì)算每個(gè)頁面的執(zhí)行時(shí)間,無需要修改頁面的相關(guān)代碼,這段代碼會給所有的頁面統(tǒng)一加上執(zhí)行時(shí)間顯示

public class PerformanceMonitorModule : IHttpModule
{
 public void Init(HttpApplication context)
 {
  context.PreRequestHandlerExecute += delegate(object sender,EventArgs e)
  {
   //Set Page Timer Star
   HttpContext requestContext = ((HttpApplication)sender).Context;
   Stopwatch timer = new Stopwatch();
   requestContext.Items["Timer"] = timer;
   timer.Start();
   };
  context.PostRequestHandlerExecute += delegate(object sender, EventArgs e)
  {
   HttpContext httpContext = ((HttpApplication)sender).Context;
   HttpResponse response = httpContext.Response;
   Stopwatch timer = (Stopwatch)httpContext.Items["Timer"];
   timer.Stop();
   // Don't interfere with non-HTML responses
   if (response.ContentType == "text/html")
   {
    double seconds = (double)timer.ElapsedTicks / Stopwatch.Frequency;
    string result_time = string.Format("{0:F4} sec ", seconds);
    RenderQueriesToResponse(response,result_time);
   }
  };
 }
 void RenderQueriesToResponse(HttpResponse response, string result_time)
 {
  response.Write("div style=\"margin: 5px; background-color: #FFFF00\"");
  response.Write(string.Format("b>Page Generated in "+ result_time));
  response.Write("/div>");
 }
 public void Dispose() { /* Not needed */ }
}

希望本文所述對大家的asp.net程序設(shè)計(jì)有所幫助。

您可能感興趣的文章:
  • ASP.NET筆記之頁面跳轉(zhuǎn)、調(diào)試、form表單、viewstate、cookie的使用說明
  • ASP.net實(shí)現(xiàn)頁面跳轉(zhuǎn)的方法
  • ASP.NET 頁面中加添加用戶控件的寫法
  • 三步將Asp.Net頁面輸出到EXCEL里
  • 設(shè)置ASP.NET頁面的運(yùn)行超時(shí)時(shí)間詳細(xì)到單個(gè)頁面及站點(diǎn)
  • asp.net截屏功能實(shí)現(xiàn)截取web頁面
  • ASP.Net頁面生成餅圖實(shí)例
  • 三種asp.net頁面跳轉(zhuǎn)的方法

標(biāo)簽:淮北 池州 樂山 賀州 固原 咸寧 廣元 吉林

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《asp.net計(jì)算每個(gè)頁面執(zhí)行時(shí)間的方法》,本文關(guān)鍵詞  asp.net,計(jì)算,每個(gè),頁面,執(zhí),;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《asp.net計(jì)算每個(gè)頁面執(zhí)行時(shí)間的方法》相關(guān)的同類信息!
  • 本頁收集關(guān)于asp.net計(jì)算每個(gè)頁面執(zhí)行時(shí)間的方法的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    新干县| 大化| 兴文县| 遵化市| 涞水县| 呼伦贝尔市| 东乌珠穆沁旗| 太湖县| 迁西县| 邻水| 高平市| 错那县| 海城市| 军事| 常熟市| 东乡族自治县| 施秉县| 广平县| 蒙城县| 道孚县| 浦县| 久治县| 兰坪| 麦盖提县| 桃园县| 报价| 新河县| 深水埗区| 米林县| 麦盖提县| 门源| 陇南市| 大关县| 望城县| 香河县| 澄城县| 四会市| 永德县| 牙克石市| 浦县| 仁布县|