作用:

微软提供的常用于统计时间消耗的类,作为一个固定的API接口供大家使用。

先看代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Threading; namespace StopWatchDemo
{
class Program
{
static void Main(string[] args)
{
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start(); int icount = ;
for (int i = ; i < ; i++)
{
for (int j = ; j < ; j++)
{
icount = i + j;
}
} stopwatch.Stop(); Console.WriteLine(stopwatch.Elapsed.TotalMilliseconds);
}
}
}

代码简化:

Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();

与下面是相同用法

Stopwatch stopwatch = Stopwatch.StartNew();

该类Stopwatch定义了一个静态的方法,用于开启计时器。

最新文章

  1. 设计模式C#合集--抽象工厂模式
  2. ASP.NET MVC5+EF6+EasyUI 后台管理系统(48)-工作流设计-起草新申请
  3. Android Ant批量打包
  4. ASP.NET Application_Error错误日志写入
  5. 17.1.4 Replication and Binary Logging Options and Variables 复制和Binary logging 选项和变量
  6. slime+sbcl for common lisp
  7. C与C++ 无参函数的区别
  8. D3.js:交互式操作
  9. js代码大全(各种方法、属性)《转载》
  10. MVC页面扩展方法 单例模式
  11. mongoDB 文档操作_增
  12. [转]OpenShift 集群搭建指南
  13. Docker registry垃圾回收
  14. 八大排序算法——插入排序(动图演示 思路分析 实例代码java 复杂度分析)
  15. 【leetcode】27-RemoveElement
  16. Java基础-算术运算符(Arithmetic Operators)
  17. gulp入门实践
  18. FasterRCNN目标检测实践纪实
  19. mongodb 两台互为主从
  20. flowable EngineConfiguration的实现分析(2)

热门文章

  1. 修改MyEclipse内存
  2. Centos 虚拟机网络问题,网卡起不来,重启network服务失败
  3. svn服务器配置 for mac
  4. Poj3087
  5. git +vs2017 操作手册+目前工作流程图
  6. “绝对”妹纸~position
  7. IO 流之字节流和转换流
  8. git 从远程仓库指定分支clone代码到本地
  9. (数据库之pymysql)
  10. 【POJ3615】Cow Hurdles 最短路,你若LCA,我仍不拦你。