C# Class Azavea.Open.Common.Chronometer

A class for timing how long things take. You can instantiate a Chronometer, or just use the static methods for timing named operations.
ファイルを表示 Open project: azavea/net-om-utils-common

Public Methods

Method Description
BeginTiming ( StringBuilder keyBuilder ) : void

Starts timing the specified named operation. Each time the same named operation is completed the time will be added to our list, so that a number of calls to the same command will give you totals, average, and number of executions.

BeginTiming ( string key ) : void

Starts timing the specified named operation. Each time the same named operation is completed the time will be added to our list, so that a number of calls to the same command will give you totals, average, and number of executions.

Chronometer ( ) : System

Creates (and starts) the timer.

EndTiming ( StringBuilder keyBuilder ) : long

Stops timing the given item and updates the timing report.

EndTiming ( string key ) : long

Stops timing the given item and updates the timing report.

GetElapsedTime ( ) : string

For display purposes, reports the run time as a long string.

GetRunTime ( ) : System.TimeSpan

How long has the timer been running.

GetSplit ( ) : System.TimeSpan

How long has the timer been running since you last called GetSplit.

GetSplitMilliseconds ( ) : string

For display purposes, reports the split time in milliseconds.

GetSplitSeconds ( ) : string

For display purposes, reports the split time in seconds.

ReportTimes ( ) : void

Reports all the times for all the operations that both BeginTiming and EndTiming were called for. This is imperfect as any call that failed may or may not have a time reported. It should, however, give a rough idea what operations are taking how long.

ReportTimes ( bool extendedStats ) : void

Reports all the times for all the operations that both BeginTiming and EndTiming were called for. This is imperfect as any call that failed may or may not have a time reported. It should, however, give a rough idea what operations are taking how long.

ReportTimes ( bool extendedStats, ReportType reportType ) : void

Reports all the times for all the operations that both BeginTiming and EndTiming were called for. This is imperfect as any call that failed may or may not have a time reported. It should, however, give a rough idea what operations are taking how long.

ReportTimes ( bool extendedStats, ReportType outType, bool printDisclaimer ) : void

Reports all the times for all the operations that both BeginTiming and EndTiming were called for. This is imperfect as any call that failed may or may not have a time reported. It should, however, give a rough idea what operations are taking how long.

Reset ( ) : void

Restarts the timer (same as calling Start() again).

Start ( ) : void

Restarts the timer.

Private Methods

Method Description
ReallyBeginTiming ( string keyWithThread ) : void

Behind the scenes we tack onto the key the name of the thread, in case multiple threads are running the same named operation at the same time.

ReallyEndTiming ( string originalKey, string keyWithThread ) : long

Behind the scenes we tack onto the key the name of the thread, in case multiple threads are running the same named operation at the same time.

Method Details

BeginTiming() public static method

Starts timing the specified named operation. Each time the same named operation is completed the time will be added to our list, so that a number of calls to the same command will give you totals, average, and number of executions.
public static BeginTiming ( StringBuilder keyBuilder ) : void
keyBuilder StringBuilder A StringBuilder containing a string that uniquely /// identifies the operation.
return void

BeginTiming() public static method

Starts timing the specified named operation. Each time the same named operation is completed the time will be added to our list, so that a number of calls to the same command will give you totals, average, and number of executions.
public static BeginTiming ( string key ) : void
key string A string that uniquely identifies the operation.
return void

Chronometer() public method

Creates (and starts) the timer.
public Chronometer ( ) : System
return System

EndTiming() public static method

Stops timing the given item and updates the timing report.
public static EndTiming ( StringBuilder keyBuilder ) : long
keyBuilder StringBuilder A StringBuilder containing a string that uniquely /// identifies the operation.
return long

EndTiming() public static method

Stops timing the given item and updates the timing report.
public static EndTiming ( string key ) : long
key string A string that uniquely identifies the operation.
return long

GetElapsedTime() public method

For display purposes, reports the run time as a long string.
public GetElapsedTime ( ) : string
return string

GetRunTime() public method

How long has the timer been running.
public GetRunTime ( ) : System.TimeSpan
return System.TimeSpan

GetSplit() public method

How long has the timer been running since you last called GetSplit.
public GetSplit ( ) : System.TimeSpan
return System.TimeSpan

GetSplitMilliseconds() public method

For display purposes, reports the split time in milliseconds.
public GetSplitMilliseconds ( ) : string
return string

GetSplitSeconds() public method

For display purposes, reports the split time in seconds.
public GetSplitSeconds ( ) : string
return string

ReportTimes() public static method

Reports all the times for all the operations that both BeginTiming and EndTiming were called for. This is imperfect as any call that failed may or may not have a time reported. It should, however, give a rough idea what operations are taking how long.
public static ReportTimes ( ) : void
return void

ReportTimes() public static method

Reports all the times for all the operations that both BeginTiming and EndTiming were called for. This is imperfect as any call that failed may or may not have a time reported. It should, however, give a rough idea what operations are taking how long.
public static ReportTimes ( bool extendedStats ) : void
extendedStats bool Show extended stats: Min, Max, StdDev, Variance.
return void

ReportTimes() public static method

Reports all the times for all the operations that both BeginTiming and EndTiming were called for. This is imperfect as any call that failed may or may not have a time reported. It should, however, give a rough idea what operations are taking how long.
public static ReportTimes ( bool extendedStats, ReportType reportType ) : void
extendedStats bool Show extended stats: Min, Max, StdDev, Variance.
reportType ReportType Print a disclaimer notice along with the times.
return void

ReportTimes() public static method

Reports all the times for all the operations that both BeginTiming and EndTiming were called for. This is imperfect as any call that failed may or may not have a time reported. It should, however, give a rough idea what operations are taking how long.
public static ReportTimes ( bool extendedStats, ReportType outType, bool printDisclaimer ) : void
extendedStats bool Show extended stats: Min, Max, StdDev, Variance.
outType ReportType The type of output to report.
printDisclaimer bool Print a disclaimer notice along with the times.
return void

Reset() public method

Restarts the timer (same as calling Start() again).
public Reset ( ) : void
return void

Start() public method

Restarts the timer.
public Start ( ) : void
return void