51 |
|
{$IFDEF UNIX}{$IFDEF UseCThreads} |
52 |
|
cthreads, |
53 |
|
{$ENDIF}{$ENDIF} |
54 |
< |
Classes, SysUtils, CustApp, IBDatabase, IBQuery |
54 |
> |
Classes, SysUtils, CustApp, IBDatabase, IBQuery, IB |
55 |
|
{ you can add units after this }; |
56 |
|
|
57 |
|
const |
91 |
|
|
92 |
|
{ TMyApplication } |
93 |
|
|
94 |
+ |
|
95 |
|
procedure TMyApplication.DoQuery; |
96 |
|
var i, rowno: integer; |
97 |
+ |
stats: TPerfCounters; |
98 |
+ |
SelectCount, InsertCount, UpdateCount, DeleteCount: integer; |
99 |
+ |
LargeCompFormat: string; |
100 |
+ |
ThreeSigPlacesFormat: string; |
101 |
|
begin |
102 |
+ |
LargeCompFormat := '#' + DefaultFormatSettings.ThousandSeparator + '##0'; |
103 |
+ |
ThreeSigPlacesFormat := '#0' + DefaultFormatSettings.DecimalSeparator + '000'; |
104 |
|
with TIBQuery.Create(self) do |
105 |
|
try |
106 |
|
AllowAutoActivateTransaction := true; |
107 |
|
Database := FIBDatabase; |
108 |
|
SQL.Text := sqlExample; |
109 |
+ |
EnableStatistics := true; |
110 |
|
Active := true; |
111 |
|
rowno := 1; |
112 |
|
while not EOF do |
121 |
|
writeln; |
122 |
|
next; |
123 |
|
end; |
124 |
+ |
if GetPerfStatistics(stats) then |
125 |
+ |
begin |
126 |
+ |
writeln('Current memory = ', FormatFloat(LargeCompFormat,stats[psCurrentMemory])); |
127 |
+ |
writeln('Delta memory = ', FormatFloat(LargeCompFormat,stats[psDeltaMemory])); |
128 |
+ |
writeln('Max memory = ', FormatFloat(LargeCompFormat,stats[psMaxMemory])); |
129 |
+ |
writeln('Elapsed time= ', FormatFloat(ThreeSigPlacesFormat,stats[psRealTime]/1000),' sec'); |
130 |
+ |
writeln('Cpu = ', FormatFloat(ThreeSigPlacesFormat,stats[psUserTime]/1000),' sec'); |
131 |
+ |
writeln('Buffers = ', FormatFloat('#0',stats[psBuffers])); |
132 |
+ |
writeln('Reads = ', FormatFloat('#0',stats[psReads])); |
133 |
+ |
writeln('Writes = ', FormatFloat('#0',stats[psWrites])); |
134 |
+ |
writeln('Fetches = ', FormatFloat('#0',stats[psFetches])); |
135 |
+ |
end; |
136 |
+ |
if StmtHandle.GetRowsAffected(SelectCount, InsertCount, UpdateCount, DeleteCount) then |
137 |
+ |
begin |
138 |
+ |
writeln('Selects = ',SelectCount); |
139 |
+ |
writeln('Inserts = ',InsertCount); |
140 |
+ |
writeln('Updates = ',UpdateCount); |
141 |
+ |
writeln('Deletes = ',DeleteCount); |
142 |
+ |
end; |
143 |
|
finally |
144 |
|
Free; |
145 |
|
end; |