Click here to Skip to main content
12,348,726 members (29,323 online)
Click here to Skip to main content
Alternatives (2)
Add your own
alternative version

Stats

88.4K views
37 bookmarked
Posted

How To: Measure execution time in C#

, 1 Mar 2011 CPOL
How To Measure execution time in C#

Alternatives

Members may post updates or alternatives to this current article in order to show different approaches or add new features.

9 Mar 2011
spot9969
Please try this method to get execution time. I'm not sure that it is very accurate.public static TimeSpan GetDuration(Stopwatch sw, ThreadStart method){ sw.Reset(); sw.Start(); method(); sw.Stop(); return sw.Elapsed;}you can put it into any common static class and use as...
26 Feb 2011
Member 7709321
Here is a useful generic class you can directly use in your project.public class Timer{ public static readonly bool IsHighPerformance; [DllImport("Kernel32.dll")] private static extern bool QueryPerformanceCounter(out long lpPerformanceCount); //Retrieves the current...

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Kanasz Robert
Architect The Staffing Edge & Marwin Cassovia Soft
Slovakia Slovakia
My name is Robert Kanasz and I have been working with ASP.NET, WinForms and C# for several years.
MCSD - Web Applications
MCSE - Data Platform
MCPD - ASP.NET Developer 3.5
- Web Developer 4
MCITP - Database Administrator 2008
- Database Developer 2008
MCSA - SQL Server 2012
MCTS - .NET Framework 3.5, ASP.NET Applications
- SQL Server 2008, Database Development
- SQL Server 2008, Implementation and Maintenance
- .NET Framework 4, Data Access
- .NET Framework 4, Service Communication Applications
- .NET Framework 4, Web Applications
MS - Programming in HTML5 with JavaScript and CSS3 Specialist

Open source projects: DBScripter - Library for scripting SQL Server database objects


Please, do not forget vote

| | Privacy | Terms of Use | Mobile
Web01 | 2.8.160621.1 | Last Updated 1 Mar 2011
Article Copyright 2011 by Kanasz Robert
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid