I'm looking for a simple, reusable way to record the time taken to execute a method in my .NET (MVC) project and record it it using NLog and wondered if anybody had any suggestions on how to implement this?
To maintain clean code and readability, I don't really want to have to integrate it into my code if possible.
If anybody has any suggestions, I'd love to hear them.
Use Stopwatch class
Stopwatch time = Stopwatch.StartNew();
time.Stop();
var milliseconds= time.ElapsedMilliseconds;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With