Home > Freeware > Zprofiler

Product Zprofiler 2.4
Description Freeware tool for optimization of Delphi programs on Pentium computers.
Created ??? ??, 1997
Last update Jun 15, 2002
OS Windows 95, 98, ME, NT, 2000, XP
Limitations Version 2.3 and up written for Delphi 4 and better
 
Details The freeware Zprofiler was written by Antonie Baars.  As original author he maintained it till version 2.2 (May 24, 1998).  I am using it since 1999.  It is one of the best programs I ever came across.  It works great, but some code needed to be updated for a new fast processors, like CPU calibrator and a like.  I have made changes it required for my own use, and decided to make them available 
for developer community the same way as original: free and with full source code.
 
Usage Drop Zprofiler component on your form, and a modeless  window will appear with a grid containing the timing results. There is only one method you need to use for marking enclosed timing blocks :
Profile.Mark(nr: Integer; aActive: boolean);
Where nr is the code block number [1..20]. Set aActibe to True to start timing and False to stop.
(Prefereably, use the global 'Profile' pointer instead of 'Zprofiler1' generated by Delphi).  If you want to put markers in project units that have no form file, add the z_prof unit in its uses section, and create the component dynamically if that has not yet been done elsewhere yet.
If you prefer to instantiate the component dynamically, put z_prof in "uses" and make the call:
TZprofiler.Create(Application.MainForm); // no reason to store result
 
Sample Profile.Mark(1, True);  // start timing fragment 1
...                     // the program code under investigation
Profile.Mark(1, False); // stop timing fragment 1
 
Precision Precision depends on execution environment, number of passes, computer load and 'hardware configuration. Below are result I am getting on my Pentium 4, 1400 MHz using 'Precision Test' application I included into Zprofiler 2.4 distribution. As you see, the overhead of timing of one code block with number of passes >= 10 is less than 3 nanoseconds.
code block passes time/ns first/ns last/ns mean/ns fastest/ns
1
2
3
4
5
6
1
10
100
1000
10000
100000
8.67
28.90
294.76
2889.76
43675.79
517165.34
8.67
2.89
8.67
2.89
11.56
11.56
8.67
2.89
2.89
2.89
2.89
2.89
8.67
2.89
2.95
2.89
4.37
5.17
8.67
2.89
2.89
2.89
2.89
2.89
 
Internals The markers act globally and are all owned by the MainForm, accessible via the pointer 
'Profile'. Only one instance of the result grid being executed. Thus, there is no point to dropping more than one Zprofiler on a form (no harm either). You can drop them on secondary forms as an easy way of updating the uses section with z_prof.  When you need more markers than the standard 20, increase the NMarks constant in z_prof.pas and recompile. The code markers act independently from each other.  This version allows timing of design mode operations as well. Set the published property: VisibleInDesignMode to True, and the grid will appear in design mode as well. Thus the behavior of custom-made components can be evaluated in design mode. Of course, the markers must be hard coded in their sources. You can hide and show the result grid in runtime by assigning false/true to the Visible property.
 
Demo The demo does not require installation of the component.  Zprofiler creates dynamically at run time. Just launch Delphi IDE, open demo.dpr and  run it.
 
Install Put files z_prof.pas, z_prof.dfm and z_prof.dcr in one of your library directories, and install component z_prof as usual. The component Zprofiler will appear on the 'Samples' page of the palette.
    
History Jan 15, 2002 - Ver 2.3

  - formatted the source code
  - changed Comp to Int64 (D4 and up)
  - rewrote CPU calibrator routine (now +/- 0.2 MHz)
  - added timing in nanoseconds (ns)
  - slightly changed UI

Jun 15, 2002 - Ver 2.4

  - added new column ('First call'), very useful for COM servers
  - exposed 'Clear' call to clear results programmatically
  - added 'Precision Test' app, to show real profiler accuracy

Screenshots  
Download  
Hosted by www.Geocities.ws

1