Click or drag to resize
Stopwatch Class
The Stopwatch data type is for measuring the time that elapses between the start and end of a programming task (wall-clock time). For an alternative, see StopwatchWin32.
Inheritance Hierarchy
SystemObject
  Algs4NetStopwatch

Namespace: Algs4Net
Assembly: Algs4Net (in Algs4Net.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
public class Stopwatch

The Stopwatch type exposes the following members.

Constructors
  NameDescription
Public methodStopwatch
Initializes a new stopwatch.
Top
Methods
  NameDescription
Public methodElapsedTime
Returns the elapsed CPU time (in seconds) since the stopwatch was created.
Public methodStatic memberMainTest
Demo test the Stopwatch data type. Takes a command-line argument n and computes the sum of the square roots of the first n positive integers, first using Math.Sqrt(), then using Math.Pow(). It prints to standard output the sum and the amount of time to compute the sum. Note that the discrete sum can be approximated by an integral - the sum should be approximately 2/3 power (n^(3/2) - 1).
Top
Remarks

For additional documentation, see Section 1.4 of Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne.

This class is a C# port from the original Java class Stopwatch implementation by the respective authors.

See Also