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

推荐订阅源

小众软件
小众软件
N
News and Events Feed by Topic
A
About on SuperTechFans
aimingoo的专栏
aimingoo的专栏
The Cloudflare Blog
H
Heimdal Security Blog
Schneier on Security
Schneier on Security
Engineering at Meta
Engineering at Meta
Google Online Security Blog
Google Online Security Blog
宝玉的分享
宝玉的分享
AI
AI
The GitHub Blog
The GitHub Blog
MongoDB | Blog
MongoDB | Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
The Last Watchdog
The Last Watchdog
T
Troy Hunt's Blog
S
Security @ Cisco Blogs
H
Hacker News: Front Page
F
Fortinet All Blogs
博客园_首页
S
Secure Thoughts
N
News and Events Feed by Topic
P
Proofpoint News Feed
Microsoft Azure Blog
Microsoft Azure Blog
I
InfoQ
Spread Privacy
Spread Privacy
Hacker News - Newest:
Hacker News - Newest: "LLM"
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Hugging Face - Blog
Hugging Face - Blog
Hacker News: Ask HN
Hacker News: Ask HN
C
CXSECURITY Database RSS Feed - CXSecurity.com
酷 壳 – CoolShell
酷 壳 – CoolShell
Stack Overflow Blog
Stack Overflow Blog
L
LINUX DO - 最新话题
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
S
Schneier on Security
Know Your Adversary
Know Your Adversary
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Scott Helme
Scott Helme
P
Privacy & Cybersecurity Law Blog
S
Securelist
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
O
OpenAI News
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
PCI Perspectives
PCI Perspectives
L
LangChain Blog
雷峰网
雷峰网
Security Archives - TechRepublic
Security Archives - TechRepublic
V2EX - 技术
V2EX - 技术

博客园 - 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)    收藏  举报

刷新页面返回顶部