I want to measure the time that certain function calls take in my application. For this I use the Stopwatch
class and it works fine. It looks something like this:
static readonly Stopwatch StopWatch = new Stopwatch();
StopWatch.Restart();
void func();
StopWatch.Stop();
Assert.Blabla
However I am typing this around a lot of functions. Is there a way to make a function that does this for me? I tried but since the signatures of the functions are all different I can't figure it out. I took a look at Func
and Action
, but they seem to require a fixed signature. I would like something like this:
CallAndMeasureFunction(func)