惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

H
Help Net Security
The GitHub Blog
The GitHub Blog
F
Fortinet All Blogs
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Simon Willison's Weblog
Simon Willison's Weblog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Cisco Talos Blog
Cisco Talos Blog
P
Privacy & Cybersecurity Law Blog
I
Intezer
Y
Y Combinator Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
N
Netflix TechBlog - Medium
The Hacker News
The Hacker News
AWS News Blog
AWS News Blog
aimingoo的专栏
aimingoo的专栏
A
About on SuperTechFans
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Stack Overflow Blog
Stack Overflow Blog
Hacker News: Ask HN
Hacker News: Ask HN
酷 壳 – CoolShell
酷 壳 – CoolShell
量子位
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
B
Blog
T
Tor Project blog
C
Cybersecurity and Infrastructure Security Agency CISA
云风的 BLOG
云风的 BLOG
博客园_首页
V2EX - 技术
V2EX - 技术
T
Threat Research - Cisco Blogs
腾讯CDC
宝玉的分享
宝玉的分享
博客园 - 叶小钗
罗磊的独立博客
S
Securelist
The Last Watchdog
The Last Watchdog
Google Online Security Blog
Google Online Security Blog
Scott Helme
Scott Helme
博客园 - 司徒正美
W
WeLiveSecurity
有赞技术团队
有赞技术团队
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
S
Secure Thoughts
NISL@THU
NISL@THU
N
News and Events Feed by Topic
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
雷峰网
雷峰网
大猫的无限游戏
大猫的无限游戏
K
Kaspersky official blog
IT之家
IT之家

博客园 - Dot-Boy

突然发现我的时间停留在2010年5月14日 vc中遇到错误提示:nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex VSS配置外部对比工具Beyond Compare C#程序集使用强名字(Strong Name)签名/强名称签名 应用程序试图执行安全策略不允许的操作。要授予此应用程序所需的权限,请与系统管理员联系,或在配置文件中更改该应用程序的信任级别 C#程序脱离.net框架的多种方法与应用 理解 Thread.Sleep 函数 SQL2005安装问题 性能监视器计数器要求 (错误) 及超强解决办法 sqlserver 大小写敏感 Lambda 表达式 SQL Server 中取得字段说明(转载) SQL Server 2005 中的分区表和索引 Analysis Services 2005中数据完整性处理(转载) 在 Microsoft Windows Server 2003 上配置对 SQL Server 2005 Analysis Services 的 HTTP 访问 Programatically recycle an IIS application pool jquery 弹出浮层(div) + 遮蔽层 - Dot-Boy 防止重复提交的方式 - Dot-Boy - 博客园 解决mysqlclient无法转换无效的时间类型 - Dot-Boy - 博客园 实现在表单内按回车键,执行指定按钮的事件 - Dot-Boy - 博客园
计算程序段运行时间
Dot-Boy · 2009-05-31 · via 博客园 - Dot-Boy

计算程序段运行时间

计算代码段运行的时间长度,用Stopwatch类

1Stopwatch sw = new Stopwatch();
2sw.Start();
3Thread.Sleep(3000);
4sw.Stop();
5Console.WriteLine(sw.ElapsedMilliseconds());

每次获取时间都要写这么几行,为此封装一个计算时间的类

Code

调用的时候:

1using (RunningTimer timer = new RunningTimer("test"))
2{
3    Thread.Sleep(3000);
4}

posted on 2009-05-31 15:03  Dot-Boy  阅读(259)  评论(0)    收藏  举报

刷新页面返回顶部