DEFINITION MODULE Timer;
(*------------------------------------------------------------------------*)
(* Einige Routinen zur Zeiterfassung. *)
(* Some routines to measure timings. *)
(*------------------------------------------------------------------------*)
(* Implementation : Michael Riedl *)
(* Licence : GNU Lesser General Public License (LGPL) *)
(*------------------------------------------------------------------------*)
(* $Id: Timer.def,v 1.2 2018/06/08 21:38:43 mriedl Exp mriedl $ *)
IMPORT UnixLib;
IMPORT SysClock;
IMPORT Streams;
TYPE tms = UnixLib.tms;
CONST HZ = SysClock.maxSecondParts; (* 100 f"ur i80386, Linux *)
PROCEDURE GetUserTime(VAR T : LONGCARD);
(*----------------------------------------------------------------*)
(* Gibt die aktuelle Systemzeit in Sekunden seit dem 01.01.1970, *)
(* 00:00 zur"uck. *)
(* *)
(* Retruns the actual system time in seconds since 01.01.1970 *)
(* 00:00 *)
(*----------------------------------------------------------------*)
PROCEDURE DeltaZeit() : CARDINAL;
(*----------------------------------------------------------------*)
(* Gibt die Zeit, die seit dem letzten Ruf dieser Prozedur ver- *)
(* strichen ist, in Sekunden zur"uck. *)
(* *)
(* Returns the time since the last call to this function in *)
(* seconds. This procedure is not thread-safe *)
(*----------------------------------------------------------------*)
PROCEDURE DeltaZeitHZ() : CARDINAL;
(*----------------------------------------------------------------*)
(* Gibt die Zeit, die seit dem letzten Ruf dieser Prozedur *)
(* verstrichen ist, in Einheiten von HZ zur"uck, wobei HZ die *)
(* maschienenabh"angige Zahl der Schl"age der Systemuhr pro *)
(* Sekunde ist. *)
(* *)
(* Returns the time since the last call to this function in *)
(* units of HZ. HZ is the machine depended number of ticks of the *)
(* system clock per second. This procedure is not thread-safe *)
(*----------------------------------------------------------------*)
PROCEDURE DeltaZeitHZr() : REAL;
(*----------------------------------------------------------------*)
(* Gibt die Zeit, die seit dem letzten Ruf dieser Prozedur *)
(* verstrichen ist, in Einheiten von HZ zur"uck, wobei HZ die *)
(* maschienenabh"angige Zahl der Schl"age der Systemuhr pro *)
(* pro Sekunde ist. Im Gegensatz zu UserTime wird die Zeit als *)
(* REAL-Varibale zur��ckgegeben die auch noch die Sekunkenbruch- *)
(* teile (abh��ngig von SysClock.maxSecondParts) enth"alt. *)
(* *)
(* Returns the time since the last call to this function in *)
(* units of HZ. HZ is the machine depended number of ticks of the *)
(* system clock per second. The return value is a real varible. *)
(* This procedure is not thread-safe *)
(*----------------------------------------------------------------*)
PROCEDURE InitUserTime(VAR t0 : tms);
(*----------------------------------------------------------------*)
(* Initialisiert UserTime. *)
(* *)
(* Initialize UserTime. *)
(*----------------------------------------------------------------*)
PROCEDURE UserTime(t0 : tms) : LONGCARD;
(*----------------------------------------------------------------*)
(* Gibt die Benutzerzeit seit dem letzten Aufruf von *)
(* InitUserTime mit demselben Argument t0 zur"uck. *)
(* *)
(* Return the user time since the last call to InitUserTime with *)
(* the same argument t0 *)
(*----------------------------------------------------------------*)
PROCEDURE UserTimeHZr(t0 : tms) : REAL;
(*----------------------------------------------------------------*)
(* Gibt die Benutzerzeit seit dem letzten Aufruf von *)
(* InitUserTime mit demselben Argument t0 zur"uck. Im Gegensatz *)
(* zu UserTime wird die Benutzerzeit als REAL-Varibale zur��ckge- *)
(* geben die auch noch den Sekunkenbruchteil (abh��ngig von *)
(* SysClock.maxSecondParts) enth"alt. *)
(* *)
(* Return the user time since the last call to InitUserTime with *)
(* the same argument t0, the return value beeing a real varibale. *)
(* That way - depending on SysClock.maxSecondPart) also parts of *)
(* a second can be taken into consideration. *)
(*----------------------------------------------------------------*)
PROCEDURE WriteDate(VAR Aus : Streams.Stream;
VAR Date : SysClock.DateTime);
(*----------------------------------------------------------------*)
(* Ausschreiben des Datums auf dem Stream Aus als DD:MM:YYYY *)
(* *)
(* Write the date provided in Date in the form DD:MM:YYY on the *)
(* stream "Aus" *)
(*----------------------------------------------------------------*)
PROCEDURE WriteTime(VAR Aus : Streams.Stream;
VAR Zeit : SysClock.DateTime);
(*----------------------------------------------------------------*)
(* Ausschreiben der Zeit auf dem Stream Aus als hh:mm:ss *)
(* *)
(* Write the date provided in Zeit in the form hh.mm:ss on the *)
(* stream "Aus" *)
(*----------------------------------------------------------------*)
END Timer.