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
| unit SomeTest;
interface
uses
Windows, Graphics, Math;
procedure DoSomeTest;
implementation
type
TD3Point = record
X, Y, Z: Double;
end;
PZPoint = ^TZPoint;
TZPoint = record
_3D: TD3Point;
_color: TColor;
_colorized: TColor;
_object: TObject;
end;
type
TPointRow = array of TZPoint;
TBuffer = array of TPointRow;
const
EmptyZPoint: TZPoint = (
_3D: (X: NaN; Y: NaN; Z: NaN);
_color: clNone; _colorized: clNone; _object: nil
);
procedure ClearABuffer(Width, Height: Integer);
var
Buffer: TBuffer;
FirstRow: TPointRow;
I, RowSize: Integer;
begin
SetLength(Buffer, Height, Width);
RowSize := Width*SizeOf(TZPoint);
// Fill the first row
FirstRow := Buffer[0];
for I := 0 to Width-1 do
FirstRow[I] := EmptyZPoint;
// Copy first row to other rows
for I := 1 to Height-1 do
Move(FirstRow[0], Buffer[I][0], RowSize);
end;
procedure DoSomeTest;
var
BeginTime, EndTime: Integer;
begin
BeginTime := GetTickCount;
ClearABuffer(1000, 1000);
EndTime := GetTickCount;
WriteLn('Elapsed: ', EndTime-BeginTime, ' miliseconds');
end;
end. |
Partager