日期:2014-05-18 浏览次数:20909 次
using System; class class1 { static StringBuilder infoAll = new StringBuilder(); private void Page_Load() { //如果要保存,将信息保存到文件中 if (Request.QueryString["save"] == "1") { System.IO.StreamWriter sw = new StreamWriter("c:\\logs\\test\\examcount.txt", true); sw.WriteLine(timeInfoAll.ToString()); sw.Close(); infoAll = new StringBuilder(); return; } //初始化 DateTime dtS = DateTime.Now; TimeSpan ts = new TimeSpan(); string timeInfo = ""; //过程1 ts = DateTime.Now - dtS; timeInfo += ";加载xml:" + ts.Milliseconds; //过程2 ts = DateTime.Now - dtS; timeInfo += "; 从库获取信息:" + ts.Milliseconds; //过程3 ts = DateTime.Now - dtS; timeInfo += "; 保存XML:" + ts.Milliseconds; if(1=1)//分支条件 Pro1(dtS, timeInfo, ts); else Pro1A(dtS, timeInfo, ts); } private void Pro1(DateTime dtS, string timeInfo, TimeSpan ts) { //过程 Pro2(dtS, timeInfo, ts); } private void Pro1A(DateTime dtS, string timeInfo, TimeSpan ts) { //过程 Pro2(dtS, timeInfo,ts); } private void Pro2(DateTime dtS, string timeInfo, TimeSpan ts) { ts = DateTime.Now - dtS; timeInfo += "; 数据处理完成:" + ts.Milliseconds; //过程4 ts = DateTime.Now - dtS; timeInfo += "; 保存XML:" + ts.Milliseconds; //过程5 ts = DateTime.Now - dtS; timeInfo += "; 保存错误数据:" + ts.Milliseconds; //过程6 ts = DateTime.Now - dtS; timeInfo += "; 保存信息到库:" + ts.Milliseconds + "\r\n"; infoAll.Append(timeInfo); } }