Click here to Skip to main content
Click here to Skip to main content

How To: Measure execution time in C#

By , 1 Mar 2011
 

Alternatives

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

1. How To: Measure execution time in C#
Updated: 9 Mar 2011
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...
C#, Visual-Studio, time, NET, execution
 
2. How To: Measure execution time in C#
Updated: 26 Feb 2011
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...
C#, Visual-Studio, time, NET, execution
 

License

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

About the Author

Kanasz Robert
Architect The Staffing Edge & Marwin Cassovia Soft
Slovakia Slovakia
Member
My name is Robert Kanasz and I have been working with ASP.NET, WinForms and C# for several years.
 
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
MCPD - ASP.NET Developer 3.5
- Web Developer 4
MCITP - Database Administrator 2008
- Database Developer 2008
 
Open source projects: DBScripter - Library for scripting SQL Server database objects
 

Please, do not forget vote

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