using System; using System.Diagnostics; using Tand.Core.Api; using Tand.Core.Models; namespace Tand.Core.Benchmarks { public class ExecutionTimeTand : ITandTarget { private readonly Stopwatch _stopwatch; private readonly Action? _resultHandler; public ExecutionTimeTand() : this(null) { } public ExecutionTimeTand(Action? resultHandler) { _stopwatch = new Stopwatch(); _resultHandler = resultHandler; } public void OnEnterMethod(CallEnterContext enterContext) { _stopwatch.Start(); } public void OnLeaveMethod(CallLeaveContext leaveContext) { _stopwatch.Stop(); _resultHandler?.Invoke($"Total execution time: {_stopwatch.Elapsed}"); } } }