Урок на Делфи 59. Замерить как быстро выполняется код


задание на delphi. Замерить время выполнени кода

unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, System.Diagnostics;
type
TForm1 = class(TForm)
Memo1: TMemo;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
timer:TStopwatch;
i:integer;
begin
timer:=TStopwatch.StartNew;
for I := 0 to 1000000000 do
Random(9999999);
timer.Stop;
Memo1.Lines.Add(timer.Elapsed.TotalMilliseconds.ToString);
end;
end.



Скачать