您的位置:首页 > 其它

监测程序运行时间的类

2012-11-21 16:13 225 查看
class Program

{

public static void Main(string[] args)

{

Stopwatch sw = new Stopwatch();

object s="";

sw.Start();

for (int i = 0; i < 100000; i++)

{

if (s == null)

{

Console.WriteLine("不为空");

}

++i;

}

sw.Stop();

Console.WriteLine(sw.Elapsed);

sw.Reset();

sw.Start();

for (int i = 0; i < 100000; i++)

{

if (s == DBNull.Value)

{

Console.WriteLine("不为空");

}

++i;

}

sw.Stop();

Console.WriteLine(sw.Elapsed);

Console.ReadKey();

//if (!DBNull.Value.Equals(s))

//{

// Console.WriteLine("不为空");

//}

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  程序 监测