App Metrics Fork me on GitHub
Show / Hide Table of Contents

Interface ITimer

A timer is basically a histogram of the duration of a type of event and a meter of the rate of its occurrence. and

Namespace:App.Metrics.Timer.Abstractions
Assembly:cs.temp.dll.dll
Syntax
public interface ITimer : IResetableMetric

Methods

CurrentTime()

This is part of advanced timer API. Use Timer.NewContext() by default. Returns the current time in nanoseconds for computing elapsed time.

Declaration
long CurrentTime()
Returns
Type Description
System.Int64

value representing the current time in nanoseconds.

EndRecording()

This is part of advanced timer API. Use Timer.NewContext() by default. Manually ends timing an action.

Declaration
long EndRecording()
Returns
Type Description
System.Int64

value representing the current time in nanoseconds.

NewContext()

Creates a new disposable instance and records the time it takes until the instance is disposed.

using(timer.NewContext())
{
ExecuteMethodThatNeedsMonitoring();
}

Declaration
TimerContext NewContext()
Returns
Type Description
TimerContext

A disposable instance that will record the time passed until disposed.

NewContext(String)

Creates a new disposable instance and records the time it takes until the instance is disposed.

using(timer.NewContext())
{
ExecuteMethodThatNeedsMonitoring();
}

Declaration
TimerContext NewContext(string userValue)
Parameters
Type Name Description
System.String userValue

A custom user value that will be associated to the results. Useful for tracking (for example) for which id the max or min value was recorded.

Returns
Type Description
TimerContext

A disposable instance that will record the time passed until disposed.

Record(Int64, TimeUnit)

This is part of advanced timer API. Use Timer.NewContext() by default. Manually record timer value.

Declaration
void Record(long time, TimeUnit unit)
Parameters
Type Name Description
System.Int64 time

The value representing the manually measured time.

TimeUnit unit

Unit for the value.

Record(Int64, TimeUnit, String)

This is part of advanced timer API. Use Timer.NewContext() by default. Manually record timer value.

Declaration
void Record(long time, TimeUnit unit, string userValue)
Parameters
Type Name Description
System.Int64 time

The value representing the manually measured time.

TimeUnit unit

Unit for the value.

System.String userValue

A custom user value that will be associated to the results. Useful for tracking (for example) for which id the max or min value was recorded.

StartRecording()

This is part of advanced timer API. Use Timer.NewContext() by default. Manually start timing an action.

Declaration
long StartRecording()
Returns
Type Description
System.Int64

value representing the current time in nanoseconds.

Time(Action)

Runs the action and records the time it took.

Declaration
void Time(Action action)
Parameters
Type Name Description
System.Action action

Action to run and record time for.

Time(Action, String)

Runs the action and records the time it took.

Declaration
void Time(Action action, string userValue)
Parameters
Type Name Description
System.Action action

Action to run and record time for.

System.String userValue

A custom user value that will be associated to the results. Useful for tracking (for example) for which id the max or min value was recorded.

Time<T>(Func<T>)

Runs the action returning the result and records the time it took.

Declaration
T Time<T>(Func<T> action)
Parameters
Type Name Description
System.Func<T> action

Action to run and record time for.

Returns
Type Description
T

The result of the action

Type Parameters
Name Description
T

Type of the value returned by the action

Time<T>(Func<T>, String)

Runs the action returning the result and records the time it took.

Declaration
T Time<T>(Func<T> action, string userValue)
Parameters
Type Name Description
System.Func<T> action

Action to run and record time for.

System.String userValue

A custom user value that will be associated to the results. Useful for tracking (for example) for which id the max or min value was recorded.

Returns
Type Description
T

The result of the action

Type Parameters
Name Description
T

Type of the value returned by the action

Back to top Copyright © 2017 Allan Hardy
Generated by DocFX