使用Stopwatch类(命名空间:System.Diagnostics;)

示例:

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SFast;
using System.Diagnostics; namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
var sw = new Stopwatch();
sw.Start();
List<Employee> employees = new List<Employee>
{
new Employee {ID = 1, Name = "Ringgo"},
new Employee {ID = 2, Name = "Rex"},
new Employee {ID = 1, Name = "Ringgo"}
};
var reslut = employees.Distinct();
sw.Stop();
Console.WriteLine(sw.ElapsedTicks);
Console.WriteLine(reslut._ToJsonStr());
Console.ReadKey();
}
}
}

结果:

.NET监视程序运行时间的更多相关文章

  1. 检测Java程序运行时间的2种方法(高精度的时间[纳秒]与低精度的时间[毫秒])

    第一种是以毫秒为单位计算的. 代码如下: long startTime=System.currentTimeMillis(); //获取开始时间 doSomeThing(); //测试的代码段 lon ...

  2. PAT乙级 1026. 程序运行时间(15)

    1026. 程序运行时间(15) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 要获得一个C语言程序的运行时间, ...

  3. VC中监测程序运行时间(二)-毫秒级

    /* * 微秒级计时器,用来统计程序运行时间 * http://blog.csdn.net/hoya5121/article/details/3778487#comments * //整理 [10/1 ...

  4. PAT-乙级-1026. 程序运行时间(15)

    1026. 程序运行时间(15) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 要获得一个C语言程序的运行时间, ...

  5. C#测量程序运行时间及cpu使用时间

    转载:http://www.cnblogs.com/yanpeng/archive/2008/10/15/1943369.html 对一个服务器程序想统计每秒可以处理多少数据包,要如何做?答案是用处理 ...

  6. java中读取程序运行时间

    第一种是以毫秒为单位计算的. Java代码 //伪代码 long startTime=System.currentTimeMillis();   //获取开始时间 doSomeThing();  // ...

  7. Java计算两个程序运行时间

    一.获取系统当前时间 long startTime = System.currentTimeMillis(); //获取开始时间 doSomething(); //测试的代码段 long endTim ...

  8. 三种计算c#程序运行时间的方法

    三种计算c#程序运行时间的方法 第一种: 利用 System.DateTime.Now // example1: System.DateTime.Now method DateTime dt1 = S ...

  9. 【转】c++ 获取程序运行时间

    转自:http://blog.csdn.net/ghevinn/article/details/22800059 DWORD start_time=GetTickCount(); {...} DWOR ...

随机推荐

  1. 【软件工程】Alpha事后诸葛亮

    链接部分 队名:女生都队 组长博客: 博客链接 作业博客:博客链接 参考邹欣老师的问题模板进行总结思考 一.设想和目标 1.我们的软件要解决什么问题?是否定义得很清楚?是否对典型用户和典型场景有清晰的 ...

  2. 自定义 TreeView 第三种状态(C#自定义控件)

    本文核心部分采用 http://blog.csdn.net/am2004/article/details/1621349 此网站代码. 在增加了部份事件的同时,将点击图片更改节点选中状态 这一小地方作 ...

  3. 映射器Mapping

    1)  org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping(核心) 将程序员定义的Action所对应的<bean& ...

  4. Ubuntu端口常用命令

    # 查看哪些进程打开了指定端口port(对于守护进程必须以root用户执行才能查看到) lsof -i:port # 查看哪些进程打开了指定端口port,最后一列是进程ID(此方法对于守护进程作用不大 ...

  5. c语言实行泛型hashmap

    代码出处:A simple string hashmap in C  https://github.com/petewarden/c_hashmap main.c (main2是官方源代码,main是 ...

  6. kubernetes/dashboard Creating sample user

    Creating sample user In this guide, we will find out how to create a new user using Service Account ...

  7. linux 自定义函数

    用别人的车子出行,总感觉别扭,那怎么自定义自己的车轮子呢? 通过上面的求两个参数的和例子,我们可以学到定义一个函数基本的步骤, function getSum(){  SUM=$[$n1+$n2]  ...

  8. robots.txt文件

    网站通过一个符合Robots协议的robots.txt文件来告诉搜索引擎哪些页面可以爬取.Robots.txt协议全称“网络爬虫排除标准”.一般情况下,该文件以一行或多行User-agent记录开始, ...

  9. 【miscellaneous】VLC组播与接收

    搭建组播服务器  第一步:运行程序后选择"媒体--串流": 第二步:通过"添加"选择需要播放的文件(以wmv文件为例),单击"串流": 第三 ...

  10. c++文件指针读写图片文件

    #include "stdafx.h"#include <string>using namespace std;int _tmain(int argc, _TCHAR* ...