Currently I am working on performance improvements in a Delphi calculation module (bpl). In past days, I found several slow code lines. We improved execution time from 8 to 3 minutes.
I found slow code lines by adding stopwatches all over the units, but making these changes is time consuming.
procedure TCalculator.Execute;
begin
TStopwatchWrapper.Start(1);
CollectValues;
TStopwatchWrapper.Pause(1);
TStopwatchWrapper.Start(2);
CalculateOrderLines;
TStopwatchWrapper.Pause(2);
...
TStopwatchWrapper.ShowTimes;
end;
procedure TCalculator.CollectValues;
begin
for {..} do
begin
{more timing}
end;
end;
The calculation units are hundreds of lines.
I would love to be able to decorate an unit, to find these slow code lines. I was thinking of Spring4D interceptors, but this only works for intercepting the external calls.
Is it possible to measure cumulative execution time per line or procedure? Without adding stopwatches or profiling calls all over the code.
Thank you in advance.