7fd59977 |
1 | |
2 | --Copyright: Matra Datavision 1992,1993 |
3 | |
4 | -- File: OSD_Timer.cdl |
5 | -- Created: Tue 18 1992 |
6 | -- Author: Stephan GARNAUD (ARM) |
7 | -- <sga@sparc4> |
8 | -- Updated: J.P. TIRAULT Sept,1993 |
9 | -- |
10 | |
11 | class Timer from OSD inherits Chronometer from OSD |
12 | |
13 | ---Purpose: Working on heterogeneous platforms |
14 | -- we need to use the system call gettimeofday. |
15 | -- This function is portable and it measures ELAPSED |
16 | -- time and CPU time in seconds and microseconds. |
17 | -- Example: OSD_Timer aTimer; |
18 | -- aTimer.Start(); // Start the timers (t1). |
19 | -- ..... // Do something. |
20 | -- aTimer.Stop(); // Stop the timers (t2). |
21 | -- aTimer.Show(); // Give the elapsed time between t1 and t2. |
22 | -- // Give also the process CPU time between |
23 | -- // t1 and t2. |
24 | |
25 | |
26 | is |
27 | |
28 | Create returns Timer from OSD; |
29 | ---Purpose: Builds a Chronometer initialized and stopped. |
30 | ---Level: Public |
31 | |
32 | Reset (me : in out) is redefined; |
33 | ---Purpose: Stops and reinitializes the timer. |
34 | ---Level: Public |
35 | |
36 | Show (me : in out) is redefined; |
37 | ---Purpose: Shows both the elapsed time and CPU time on the standard output |
38 | -- stream <cout>.The chronometer can be running (Lap Time) or |
39 | -- stopped. |
40 | ---Level: Public |
41 | |
42 | Show (me : in out; os : in out OStream from Standard) is redefined; |
43 | ---Purpose: Shows both the elapsed time and CPU time on the |
44 | -- output stream <OS>. |
45 | ---Level: Public |
46 | |
47 | Show (me : in out; seconds : in out Real from Standard; |
48 | minutes : in out Integer from Standard; |
49 | hours : in out Integer from Standard; |
50 | CPUtime : in out Real from Standard); |
51 | |
52 | ---Purpose: returns both the elapsed time(seconds,minutes,hours) |
53 | -- and CPU time. |
54 | ---Level: Public |
55 | |
56 | Stop (me : in out) is redefined; |
57 | ---Purpose: Stops the Timer. |
58 | ---Level: Public |
59 | |
60 | Start (me : in out) is redefined; |
61 | ---Purpose: Starts (after Create or Reset) or restarts (after Stop) |
62 | -- the Timer. |
63 | ---Level: Public |
64 | |
65 | fields |
66 | |
67 | TimeStart : Real; |
68 | TimeCumul : Real; |
69 | |
70 | end; |