Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2003.12.23;
Скачать: CL | DM;

Вниз

Скорость выполнения процедуры   Найти похожие ветки 

 
DNT ©   (2003-12-11 16:54) [0]

Подскажите как посчитать скорость выполнения процедуры, в милесекундах например.

Заранее спасибо ;)


 
Jel ©   (2003-12-11 16:55) [1]

GetTickCount до и после.


 
DNT ©   (2003-12-11 16:55) [2]

P.S. Я не знаю как время получить, более точное чем секунда.
В этом вся загвоздка.


 
panov ©   (2003-12-11 19:48) [3]

Help-->Windows SDK-->GetTickCount


 
Александр из Минска ©   (2003-12-11 21:02) [4]

ПОпробуй так: (у меня показывает милисеки, но я не уверен)
var
i : Integer;
bt : TDateTime;
h, m, s, ms : Word;
begin
bt := Time;
for i := 1 to 100000000 do
begin
end;
DecodeTime(Time-bt, h, m, s, ms);
ShowMessage(IntToStr(ms));
end;


 
panov ©   (2003-12-11 21:16) [5]

Если сложно разобраться, то вот пример...
unit uTimer;

interface

uses
Classes,windows,Messages,forms;

const
WM_FTIMER = WM_USER+10000;

type
TFTimer = class(TThread)
hParent: Thandle;
FInterval: Integer;
private
Exists: Boolean;
STime: Int64;
CTime: Int64;
StartTime : Double;
ClockRate : Double;
protected
procedure Execute; override;
public
function StartTimer : Boolean;
function ReadTimer : Double;
constructor Create(aParentHandle: THandle;aInterval: Integer);
end;

implementation

constructor TFTimer.Create(aParentHandle: THandle;aInterval: Integer);
var
QW : Int64;
begin
inherited Create(True);
hParent := aParentHandle;
FInterval := aInterval;
FreeOnTerminate := True;
Exists := QueryPerformanceFrequency(QW);
ClockRate := QW;
STime := getTickCount;
// Priority := tpTimeCritical;
StartTimer;
Resume;
end;

function TFTimer.StartTimer : Boolean;
var
QW : Int64;
begin
Result := QueryPerformanceCounter(QW);
StartTime := QW;
end;

function TFTimer.ReadTimer : Double;
var
ET : Int64;
begin
QueryPerformanceCounter(ET);
Result := 10.0*(ET - StartTime)/ClockRate;
end;

procedure TFTimer.Execute;
var
n: Int64;
begin
n := 0;
while not Terminated do
begin
n := GetTickCount - STime;
Application.ProcessMessages;
if n >= FInterval then
begin
Stime := GetTickCount;
PostMessage(hParent,WM_FTIMER,0,n);
end;

// windows.Sleep(FInterval);
// inc(n);
// PostMessage(hParent,WM_FTIMER,0,0);
end;

end;

end.


 
Deb ©   (2003-12-12 02:16) [6]

function GetTime:int64;
asm
{$IFDEF VER140} //Для Delphi 6.x
rdtsc
{$ELSE} //Для Delphi 5.x
db 0Fh, 31h
{$ENDIF}
end;

и юзаем:
procTime:=GetTime;
// процедура
procTime:=GetTime - procTime;

Результат возвращается в тактах, погрешность до одного такта



Страницы: 1 вся ветка

Текущий архив: 2003.12.23;
Скачать: CL | DM;

Наверх




Память: 0.48 MB
Время: 0.013 c
14-75386
Igorek
2003-11-27 21:15
2003.12.23
Что делать, когда все в лом?


1-75259
selena
2003-12-10 08:11
2003.12.23
кодировка


4-75452
Dimonn
2003-10-28 11:19
2003.12.23
VirtualAlloc


1-75250
Serg777
2003-12-10 13:44
2003.12.23
Вывод на матричный принтер


4-75453
sashag
2003-10-27 18:57
2003.12.23
Запуск внешней консольной программы