于野 wrote:
> I'm a Chinese OIer(which is short for someone who has intersts in
> 'Olympiad in Informatics'). Now I'm using Lazarus to debug. but every time
> when I want to know how much time it spend during the program runs, I have
> to add something like this: var ta,tb:Tsystemtime;
> begin
>   datetimetosystemtime(now,ta);
>   ........
>   ........
>   datetimetosystemtime(now,tb);
>   writeln(....);
> end.
> It's so boring.

I got bored too, so I wrote TElapsed.

Thanks!

--
Al


unit elapsed; 

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils;

type

  { TElapsed }

  TElapsed = class(TComponent)
  private
    FStart:TDateTime;
  public
    procedure Start;
    function ms: integer;
    function mss: string;
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('Standard', [TElapsed]);
end;


{ TElapsed }

procedure TElapsed.Start;
begin
  FStart:=Now;
end;

function TElapsed.ms: integer;
begin
  Result:=DateTimeToTimeStamp(Now-FStart).Time;
end;

function TElapsed.mss: string;
begin
  Result:=IntToStr(ms);
end;

initialization

end.

Reply via email to