⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fasttime.pas

📁 East make Tray Icon in delphi
💻 PAS
字号:
//-----------------------------------------------------------------------
// A fast timer.  Based upon original code (TmwFastTime) by Martin
// Waldenburg in 1996.  This version descends from TObject, so we
// don't have to mess around installing it on the component palette.
//-----------------------------------------------------------------------

unit FastTime;

interface

uses
  SysUtils, Windows, Classes;

type
    TFastTimer = class(TObject)
    private
        nStart, nStop: TLargeInteger;
        function GetElapsedTime: String;
        function GetElapsed: Extended;
        function GetElapsedMicroSeconds: TLargeInteger;
    public
        property Elapsed: Extended read GetElapsed;
        property ElapsedMicroseconds: TLargeInteger read GetElapsedMicroSeconds;
        property ElapsedTime: String read GetElapsedTime;
        procedure Start;
        procedure Stop;
    end;

var
    FastTimer: TFastTimer;
    Frequency: TLargeInteger;

implementation

function TFastTimer.GetElapsed: Extended;
begin
    Result:= (nStop - nStart) / Frequency;
end;

function TFastTimer.GetElapsedTime: String;
begin
    Result := Format ('Seconds: %g', [GetElapsed]);
end;

function TFastTimer.GetElapsedMicroSeconds: TLargeInteger;
begin
    Result := Trunc (GetElapsed * 1000000.0);
end;

procedure TFastTimer.Start;
begin
    QueryPerformanceCounter (nStart);
end;

procedure TFastTimer.Stop;
begin
    QueryPerformanceCounter (nStop);
end;

initialization
    QueryPerformanceFrequency (Frequency);
    FastTimer := TFastTimer.Create;
finalization
    FastTimer.Free;
end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -