Watch
Provides utility methods for timing the execution of code.
Métodos
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.
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.
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.
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.
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.