Class Profiler
Provides operations for profiling the code.
Inheritance
Inherited Members
Namespace: Kephas.Diagnostics
Assembly: Kephas.Core.dll
Syntax
public static class Profiler
Methods
| Improve this Doc View SourceWithDebugStopwatch(Action, ILogger, String)
Executes the action with a stopwatch, optionally logging the elapsed time at Debug level.
Declaration
public static TimeSpan WithDebugStopwatch(Action action, ILogger logger = null, string memberName = null)
Parameters
Type | Name | Description |
---|---|---|
System.Action | action | The action. |
ILogger | logger | The logger. |
System.String | memberName | Name of the member. |
Returns
Type | Description |
---|---|
System.TimeSpan | The elapsed time. |
WithDebugStopwatchAsync(Func<Task>, ILogger, String)
Executes the action with a stopwatch for asynchronous actions, optionally logging the elapsed time at Debug level.
Declaration
public static Task<TimeSpan> WithDebugStopwatchAsync(Func<Task> action, ILogger logger = null, string memberName = null)
Parameters
Type | Name | Description |
---|---|---|
System.Func<System.Threading.Tasks.Task> | action | The action. |
ILogger | logger | The logger. |
System.String | memberName | Name of the member. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.TimeSpan> | The elapsed time. |
WithInfoStopwatch(Action, ILogger, String)
Executes the action with a stopwatch, optionally logging the elapsed time at Info level.
Declaration
public static TimeSpan WithInfoStopwatch(Action action, ILogger logger = null, string memberName = null)
Parameters
Type | Name | Description |
---|---|---|
System.Action | action | The action. |
ILogger | logger | The logger. |
System.String | memberName | Name of the member. |
Returns
Type | Description |
---|---|
System.TimeSpan | The elapsed time. |
WithInfoStopwatchAsync(Func<Task>, ILogger, String)
Executes the action with a stopwatch for asynchronous actions, optionally logging the elapsed time at Info level.
Declaration
public static Task<TimeSpan> WithInfoStopwatchAsync(Func<Task> action, ILogger logger = null, string memberName = null)
Parameters
Type | Name | Description |
---|---|---|
System.Func<System.Threading.Tasks.Task> | action | The action. |
ILogger | logger | The logger. |
System.String | memberName | Name of the member. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.TimeSpan> | The elapsed time. |
WithStopwatch(Action, ILogger, LogLevel, String)
Executes the action with a stopwatch, optionally logging the elapsed time at the indicated log level.
Declaration
public static TimeSpan WithStopwatch(Action action, ILogger logger = null, LogLevel logLevel = LogLevel.Debug, string memberName = null)
Parameters
Type | Name | Description |
---|---|---|
System.Action | action | The action. |
ILogger | logger | The logger. |
LogLevel | logLevel | The log level. |
System.String | memberName | Name of the member. |
Returns
Type | Description |
---|---|
System.TimeSpan | The elapsed time. |
WithStopwatchAsync(Func<Task>, ILogger, LogLevel, String)
Executes the action with a stopwatch for asynchronous actions, optionally logging the elapsed time at the indicated log level.
Declaration
public static Task<TimeSpan> WithStopwatchAsync(Func<Task> action, ILogger logger = null, LogLevel logLevel = LogLevel.Debug, string memberName = null)
Parameters
Type | Name | Description |
---|---|---|
System.Func<System.Threading.Tasks.Task> | action | The action. |
ILogger | logger | The logger. |
LogLevel | logLevel | The log level. |
System.String | memberName | Name of the member. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.TimeSpan> | The elapsed time. |
WithTraceStopwatch(Action, ILogger, String)
Executes the action with a stopwatch, optionally logging the elapsed time at Trace level.
Declaration
public static TimeSpan WithTraceStopwatch(Action action, ILogger logger = null, string memberName = null)
Parameters
Type | Name | Description |
---|---|---|
System.Action | action | The action. |
ILogger | logger | The logger. |
System.String | memberName | Name of the member. |
Returns
Type | Description |
---|---|
System.TimeSpan | The elapsed time. |
WithTraceStopwatchAsync(Func<Task>, ILogger, String)
Executes the action with a stopwatch for asynchronous actions, optionally logging the elapsed time at Trace level.
Declaration
public static Task<TimeSpan> WithTraceStopwatchAsync(Func<Task> action, ILogger logger = null, string memberName = null)
Parameters
Type | Name | Description |
---|---|---|
System.Func<System.Threading.Tasks.Task> | action | The action. |
ILogger | logger | The logger. |
System.String | memberName | Name of the member. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.TimeSpan> | The elapsed time. |
WithWarningStopwatch(Action, ILogger, String)
Executes the action with a stopwatch, optionally logging the elapsed time at Warning level.
Declaration
public static TimeSpan WithWarningStopwatch(Action action, ILogger logger = null, string memberName = null)
Parameters
Type | Name | Description |
---|---|---|
System.Action | action | The action. |
ILogger | logger | The logger. |
System.String | memberName | Name of the member. |
Returns
Type | Description |
---|---|
System.TimeSpan | The elapsed time. |
WithWarningStopwatchAsync(Func<Task>, ILogger, String)
Executes the action with a stopwatch for asynchronous actions, optionally logging the elapsed time at Warning level.
Declaration
public static Task<TimeSpan> WithWarningStopwatchAsync(Func<Task> action, ILogger logger = null, string memberName = null)
Parameters
Type | Name | Description |
---|---|---|
System.Func<System.Threading.Tasks.Task> | action | The action. |
ILogger | logger | The logger. |
System.String | memberName | Name of the member. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.TimeSpan> | The elapsed time. |