timer.pas 857 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. unit timer;
  2. interface
  3. uses
  4. SysUtils;
  5. var
  6. verbosetimer : boolean = true;
  7. procedure start;
  8. procedure stop;
  9. function MSec:cardinal;
  10. implementation
  11. var
  12. stime,etime : cardinal;
  13. function gt : cardinal;
  14. var
  15. h,m,s,s1000 : word;
  16. begin
  17. decodetime(time,h,m,s,s1000);
  18. gt:=h*3600000+m*60000+s*1000+s1000;
  19. {
  20. gettime(h,m,s,s100);
  21. gt:=h*360000+m*6000+s*100+s100;
  22. }
  23. end;
  24. procedure start;
  25. begin
  26. stime:=gt;
  27. end;
  28. procedure stop;
  29. var
  30. s : cardinal;
  31. begin
  32. etime:=gt;
  33. s:=etime-stime;
  34. if verbosetimer then
  35. write(stderr,s div 1000,'.',s mod 1000,' Seconds');
  36. end;
  37. function MSec:cardinal;
  38. begin
  39. Msec:=etime-stime;
  40. end;
  41. end.