Profiler

A profiler is used to find bottle necks in an applications processing. These can effect an applications initialization, loading data, processing and general response. This can have a critical effect on a users perception of the value of both inhouse and commercial appliactions.

A profiler measures and records the time taken to execute each method within an application. This is achieved within the Delphi environment by planting calls to the profiler at the beginning and end of each method.

procedure PaintLine(Canvas: TCanvas; I, Len: Integer);
begin
{$IFDEF XPGPROFILE} XPGMethodStart($199645);try{$ENDIF}

  Canvas.PolyLine([Point(0, I * 2 + 1), Point(Len, I * 2 + 1)]);

{$IFDEF XPGPROFILE} finally XPGMethodFinish($199645);end;{$ENDIF}
end;

It can handle,

  • 1024 units
  • 16384 classes per unit
  • 65536 method per class

The profiler measures time spent solely in a method, time soent in sub calls and total time. For example if we had three methods "Bar", "Foo" and "Max", where "Bar" calls "Foo" and "Max", and "Max" calls "Bar". The execution time-line might look something like this,

Here we have,

	Time solely in "Bar" = T1 + T3 + T5 + T7
	Time solely in "Foo" = T2
	Time solely in "Max" = T4 + T6

	Sub call time "Bar" = T2 + T4 + T6
	Sub call time "Foo" = 0
	Sub call time "Max" = T5
	
	Total time "Bar" = T1 + T2 + T3 + T4 + T5 + T6 + T7
	Total time "Foo" = T2
	Total time "Max" = T4 + T5 + T6

This breakdown allows you to identify where most processing time is being spent.

See the following sections on the profiler facility,

<< Source Area Contents Add Profiling Code >>
Copyright © 2005-2010, Simon Cox