-
Notifications
You must be signed in to change notification settings - Fork 1
/
Timing_lib.pas
77 lines (67 loc) · 1.39 KB
/
Timing_lib.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
unit Timing_lib;
interface
uses
Windows, OpenGL,
Engine_Reg,
Func_lib,
Type_Lib;
procedure Timing_Start(paramname : string);
procedure Timing_End(paramname : string);
procedure Timing_Draw;
implementation
var
tt: array [0..100] of string;
ts, tm: array [0..100] of integer;
cc: integer = 0;
function GetTimer: integer;
var
T, F : LARGE_INTEGER;
begin
QueryPerformanceFrequency(int64(F));
QueryPerformanceCounter(int64(T));
Result := trunc(1000 * T.QuadPart/F.QuadPart);
end;
procedure Timing_Start(paramname : string);
var
i: integer;
begin
for i:=0 to cc-1 do
if tt[i]=paramname then
begin
ts[i]:=GetTimer;
Exit;
end;
Inc(cc);
tt[cc-1]:=paramname;
ts[cc-1]:=GetTimer;
end;
procedure Timing_End(paramname : string);
var
i: integer;
begin
for i:=0 to cc-1 do
if tt[i]=paramname then
begin
tm[i]:=GetTimer-ts[i];
Exit;
end;
Inc(cc);
tt[cc-1]:=paramname;
tm[cc-1]:=0;
end;
procedure Timing_Draw;
var
i: integer;
begin
xglAlphaBlend(1);
for i:=0 to cc-1 do
begin
glColor3f(0, 0, 0);
TextOut(500, 51+i*16, PChar(tt[i]));
TextOut(600, 51+i*16, PChar(inttostr(tm[i])));
glColor3f(1, 0.2, 0.2);
TextOut(500, 51+i*16, PChar(tt[i]));
TextOut(600, 51+i*16, PChar(inttostr(tm[i])));
end;
end;
end.