How can I detect elapsed time in Pascal?

拈花ヽ惹草 提交于 2019-12-04 10:12:50

Check this link. There might be some useful information for you. And here is the same you're asking for. And here's what you're looking for (same as the code below).

var hours: word;
    minutes: word;
    seconds: word;
    milliseconds: word;

procedure StartClock;
begin
  GetTime(hours, minutes, seconds, milliseconds);
end;

procedure StopClock;
var seconds_count : longint;
    c_hours: word;
    c_minutes: word;
    c_seconds: word;
    c_milliseconds: word;

begin
  GetTime(c_hours, c_minutes, c_seconds, c_milliseconds);
  seconds_count := c_seconds - seconds + (c_minutes - minutes) * 60 + (c_hours - hours) * 3600;
  writeln(inttostr(seconds_count) + ' seconds');
end;

begin
  StartClock;

  // code you want to measure

  StopClock;
end.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!