📄 debug.pas
字号:
unit Debug;
interface
{$IFDEF MSWINDOWS}
uses
Windows;
{$ENDIF}
type
{$IFDEF MSWINDOWS}
TTimeType = DWORD;
{$ELSE}
TTimeType = TDateTime;
{$ENDIF}
TTickInfo = class
private
StartTime: TTimeType;
StopTime: TTimeType;
Working: boolean;
public
procedure Start;
procedure Stop;
function GetCurrent: TTimeType;
function GetInterval: TTimeType;
function GetIntervalSt: string;
end;
function IntervalToStr(T: TTimeType):string;
implementation
uses
SysUtils;
function TTickInfo.GetCurrent: TTimeType;
begin
{$IFDEF MSWINDOWS}
Result := GetTickCount;
{$ELSE}
Result := Time;
{$ENDIF}
end;
procedure TTickInfo.Start;
begin
Working := True;
StartTime := GetCurrent;
end;
procedure TTickInfo.Stop;
begin
StopTime := GetCurrent;
Working := False;
end;
function TTickInfo.GetInterval:TTimeType;
begin
if Working then
Result := GetCurrent - StartTime
else
Result := StopTime - StartTime;
end;
function TTickInfo.GetIntervalSt:string;
begin
Result := IntervalToStr(GetInterval);
end;
function IntervalToStr(T: TTimeType):string;
{$IFDEF MSWINDOWS}
var
St: string;
{$ENDIF}
begin
{$IFDEF MSWINDOWS}
if T > 60000 then begin
Result:= IntToStr(T div 60000) + ':';
T:= T mod 60000;
end
else
Result:= '0:';
if T > 1000 then
Result:= Result + IntToStr(T div 1000) + ':'
else
Result:= Result + '0:';
St:= IntToStr(T mod 1000);
while Length(St) < 3 do
St:= '0' + St;
Result:= Result + St;
{$ELSE}
Result := TimeToStr(T);
{$ENDIF}
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -