79756262

Date: 2025-09-04 22:12:13
Score: 0.5
Natty:
Report link

I needed to also return value from a function and my approach was as follows:

public class PerformanceTests
{
    private readonly stopwatch = new();

    public (T Result, TimeSpan Elapsed) MeasureExecutionTime<T>(Func<T> function)
    {
        stopwatch.Restart();
        var result = function();
        stopwatch.Stop();
        return (result, stopwatch.Elapsed);
    }
}
Reasons:
  • Blacklisted phrase (0.5): I need
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Gucu112