Click here to Skip to main content
15,895,084 members
Articles / Programming Languages / C#

High-Performance Timer in C#

Rate me:
Please Sign up or sign in to vote.
4.81/5 (54 votes)
29 Jul 2002CPOL2 min read 594.3K   5.3K   135  
A C# class to provide exact time measurement in your applications
In this article, you will see a C# class which can provide exact time measurement in applications.
using System;
using Win32;

namespace HighPerformanceTimer
{
	/// <summary>
	/// Zusammendfassende Beschreibung f�r Class1.
	/// </summary>
	class Class1
	{
		/// <summary>
		/// Der Haupteinstiegspunkt f�r die Anwendung.
		/// </summary>
		[STAThread]
		static void Main(string[] args)
		{
			//
			// TODO: F�gen Sie hier Code hinzu, um die Anwendung zu starten
			//
            HiPerfTimer pt = new HiPerfTimer();                    // create a new PerfTimer object
            pt.Start();                                            // start the timer
            Console.WriteLine("Test\n");                           // the code to be timed
            pt.Stop();                                             // stop the timer
            Console.WriteLine("Duration: {0} sec\n", pt.Duration); // print the duration of the timed code

            Console.ReadLine();
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

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


Written By
Austria Austria
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions