Fórum Timer < que 1ms #415120
07/04/2012
0
Preciso contar tempo menor que 1ms
Em minha aplicação o tempo varia de 0,5ms a 1,5ms
Daí que o timer só aceita integer e não dá para quebrar menor que 1 ms.
Alguma santa alma poderia me dar uma dica de como faço uma thred para isso ou algo que funcione?
Grato pela força e bom feriado.
Malereis
Alexandre
Curtir tópico
+ 0Posts
08/04/2012
Marco Salles
http://marcosalles.wordpress.com/?p=692&preview=true
Gostei + 0
08/04/2012
Alexandre
Valeu pela dica.
Abraços
Gostei + 0
08/04/2012
Marco Salles
http://marcosalles.wordpress.com/?p=692&preview=true
<a href=http://marcosalles.wordpress.com/?p=692&preview=true class=postlink>http://marcosalles.wordpress.com/?p=692&preview=true/</a>
Gostei + 0
09/04/2012
Alexandre
Nesse link http://marcosalles.wordpress.com/?p=692&preview=true
No código que vc mencionou, o que significa essa linha, abaixo de type?
[{9B36187D-CD62-4A9D-969B-23D9B512A659}]
Parece um serial......
Grato
Malereis
Gostei + 0
09/04/2012
Alexandre
No Delphi 7 parece que não dá para declarar em uses Diagnostics.
Grato
Gostei + 0
09/04/2012
Marco Salles
Digite CNTR + SHIFT + G no seu editor de código que ele gerará um valor
igual a este
quanto a voce utilizar o Delphi 7 , voce tem que implemetar a classe
Tire a referencia a unidade Diagnostics defina uma nova Unidade no seu exemplo
De uses a esta Unidade e mande Bala
unit StopWatch;
interface
uses Windows, SysUtils, DateUtils;
type TStopWatch = class
private
fFrequency : TLargeInteger;
fIsRunning: boolean;
fIsHighResolution: boolean;
fStartCount, fStopCount : TLargeInteger;
procedure SetTickStamp(var lInt : TLargeInteger) ;
function GetElapsedTicks: TLargeInteger;
function GetElapsedMiliseconds: TLargeInteger;
function GetElapsed: string;
public
constructor Create(const startOnCreate : boolean = false) ;
procedure Start;
procedure Stop;
property IsHighResolution : boolean read fIsHighResolution;
property ElapsedTicks : TLargeInteger read GetElapsedTicks;
property ElapsedMiliseconds : TLargeInteger read GetElapsedMiliseconds;
property Elapsed : string read GetElapsed;
property IsRunning : boolean read fIsRunning;
end;
implementation
constructor TStopWatch.Create(const startOnCreate : boolean = false) ;
begin
inherited Create;
fIsRunning := false;
fIsHighResolution := QueryPerformanceFrequency(fFrequency) ;
if NOT fIsHighResolution then fFrequency := MSecsPerSec;
if startOnCreate then Start;
end;
function TStopWatch.GetElapsedTicks: TLargeInteger;
begin
result := fStopCount - fStartCount;
end;
procedure TStopWatch.SetTickStamp(var lInt : TLargeInteger) ;
begin
if fIsHighResolution then
QueryPerformanceCounter(lInt)
else
lInt := MilliSecondOf(Now) ;
end;
function TStopWatch.GetElapsed: string;
var
dt : TDateTime;
begin
dt := ElapsedMiliseconds / MSecsPerSec / SecsPerDay;
result := Format(%d days, %s, ) ;
end;
function TStopWatch.GetElapsedMiliseconds: TLargeInteger;
begin
result := (MSecsPerSec * (fStopCount - fStartCount)) div fFrequency;
end;
procedure TStopWatch.Start;
begin
SetTickStamp(fStartCount) ;
fIsRunning := true;
end;
procedure TStopWatch.Stop;
begin
SetTickStamp(fStopCount) ;
fIsRunning := false;
end;
end.
Gostei + 0
09/04/2012
Alexandre
Grato pela dica..
Vou implementar.
Abraços
Malereis
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)