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

📄 main.pas

📁 High Accuracy Timer Component
💻 PAS
字号:
unit main;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Controls, Forms,
  StdCtrls, Buttons;

type

  TForm1 = class(TForm)
    btnStart: TBitBtn;
    Memo1: TMemo;
    procedure FormCreate(Sender: TObject);
    procedure btnStartClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

  Mem: Cardinal;

implementation

uses SZTimer;

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  btnStart.Click;
end;

procedure TForm1.btnStartClick(Sender: TObject);
var
  t: TSZTimer;
  d: extended;
  i: integer;
begin
  SZBeforeBenchmark;

  memo1.Clear;

  t.Start; sleep(1000); t.Stop;

  Memo1.Lines.Add('Sleep 1000ms : '+t.PrintRDTSC+' CPU Clock Cycles');
  Memo1.Lines.Add('Sleep 1000ms : '+t.Print);

  Memo1.Lines.Add('');
  Memo1.Lines.Add('CPU Speed : '+format('%.6n MHz',[t.ElapsedRDTSC/1000000]));
  Memo1.Lines.Add('');


  t.Start;

  d:=0;
  for i:=0 to 255 do
    d:=d+sin(4/3 * PI);

  t.Stop;

  Memo1.Lines.Add(format('sin = %f : %s CPU Clock Cycles',[d, t.PrintRDTSC]));
  Memo1.Lines.Add('');

  t.Start;

  d:=0;
  for i:=0 to 255 do
    d:= d + sin(4/3 * PI) + sin(4/3 * PI);

  t.Stop;

  Memo1.Lines.Add(format(' sin + sin = %f : %s CPU Clock Cycles',[d, t.PrintRDTSC]));
  Memo1.Lines.Add('');

  SZAfterBenchmark;


end;

end.

⌨️ 快捷键说明

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