Watch

Ecng.Common

Provides utility methods for timing the execution of code.

Métodos

Do
public static TimeSpan Do(Action action)
result = Watch.Do(action)

Executes the specified action, measures its execution time, and returns the elapsed time.

action
The action to execute.

Retorna: A TimeSpan representing the elapsed time during the execution of the action.

DoAsync
public static Task<TimeSpan> DoAsync(Func<Task> func)
result = Watch.DoAsync(func)

Executes the specified asynchronous function, measures its execution time, and returns the elapsed time.

func
The asynchronous function to execute.

Retorna: A Task representing the asynchronous operation that returns the elapsed time during the execution of the function.

DoAsync
public static ValueTask<TimeSpan> DoAsync(Func<ValueTask> func)
result = Watch.DoAsync(func)

Executes the specified asynchronous function that returns a ValueTask, measures its execution time, and returns the elapsed time.

func
The asynchronous function to execute.

Retorna: A ValueTask representing the asynchronous operation that returns the elapsed time during the execution of the function.

DoAsync``1
public static Task<ValueTuple<T, TimeSpan>> DoAsync<T>(Func<Task<T>> func)
result = Watch.DoAsync(func)

Executes the specified asynchronous function, measures its execution time, and returns both the result and the elapsed time.

func
The asynchronous function to execute.

Retorna: A Task representing the asynchronous operation that returns a tuple containing the result and the elapsed time during the execution of the function.

DoAsync``1
public static ValueTask<ValueTuple<T, TimeSpan>> DoAsync<T>(Func<ValueTask<T>> func)
result = Watch.DoAsync(func)

Executes the specified asynchronous function that returns a ValueTask, measures its execution time, and returns both the result and the elapsed time.

func
The asynchronous function to execute.

Retorna: A ValueTask representing the asynchronous operation that returns a tuple containing the result and the elapsed time during the execution of the function.