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

📄 functimeru.pas

📁 DelphiWin32核心API参考光盘内容.是学习书籍中的源码,便于学习.
💻 PAS
字号:
unit FuncTimerU;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Grids;

type
  TForm1 = class(TForm)
    StringGrid1: TStringGrid;
    Button1: TButton;
    Label1: TLabel;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var
  Loop1, Loop2: Integer;        // general loop control counters
  StartCount,                   // this holds the start and stop time for
  EndCount: TLargeInteger;      // the function
  Frequency: TLargeInteger;     // the frequency of the high resolution timer
  ElapsedTime: Extended;        // holds the total elapsed time
begin
  {retrieve the frequency of the high resolution timer}
  QueryPerformanceFrequency(Frequency);

  {begin timing the function by retrieving the current
   value of the high resolution timer}
  QueryPerformanceCounter(StartCount);

  {perform some function. in this example, we fill a 100 X 100
   cell string grid with numbers.}
  for Loop1 := 0 to 99 do
    for Loop2 :=0 to 99 do
      StringGrid1.Cells[Loop2, Loop1] := IntToStr((Loop1*100)+Loop2);

  {the function is complete. retrieve the current value
   of the high resolution counter as our end count}
  QueryPerformanceCounter(EndCount);

  {this formula computes the total amount of time the function
   took to complete}
  ElapsedTime := (EndCount - StartCount)/Frequency;

  {display the elapsed time, in seconds}
  Label1.Caption := 'Elapsed Time: '+FloatToStr(ElapsedTime)+' seconds.';
end;

end.

⌨️ 快捷键说明

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