Thema: timeGetTime

Einzelnen Beitrag anzeigen

Benutzerbild von markus5766h
markus5766h

Registriert seit: 5. Mär 2009
Ort: Hamburg
569 Beiträge
 
Delphi XE8 Professional
 
#22

Re: timeGetTime

  Alt 11. Jan 2010, 16:51
Hallo,
als Konsolenanwendung waren meine "Tick"-Werte schön konstant,
als Windows-Anwendung variiren sie stark, siehe Anhang

Delphi-Quellcode:
uses
  Windows, mmsystem, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Grids;

type
  TForm1 = class(TForm)
    Grid1: TStringGrid;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
    Times : array[1..4, 0..50] of Cardinal;
    LastTick, LastTime : Cardinal;
    procedure SetTimes;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.SetTimes;
var
 i : Integer;
begin
 LastTick := 0;
 LastTime := 0;
 i := 50;

 while (i > 0) do
  begin
   Times[1, i] := GetTickCount;
   Times[2, i] := TimeGetTime;
   Times[3, i] := Times[1, i] - LastTick;
   Times[4, i] := Times[2, i] - LastTime;
   LastTick := Times[1, i];
   LastTime := Times[2, i];
   Sleep(53);
   Dec(i);
  end; // end i > 0
end;

procedure TForm1.Button1Click(Sender: TObject);
var
 c, r : Integer;
begin
SetTimes;
Grid1.Cells[1, 0] := 'Tick';
Grid1.Cells[2, 0] := 'Time';
Grid1.Cells[3, 0] := 'Tick-LastTick';
Grid1.Cells[4, 0] := 'Time-LastTime';

for r := 0 to 50 do
 begin
  Grid1.Cells[0, r+1] := IntToStr(r);
   for c := 1 to 4 do
    begin
     Grid1.Cells[c, r+1] := IntToStr(Times[c, 50-r]);
    end;
 end;
end;
Miniaturansicht angehängter Grafiken
projekt14_206.jpg   projekt4_120.jpg  
Markus H.
  Mit Zitat antworten Zitat