home *** CD-ROM | disk | FTP | other *** search
- -- Chapter 24 - Program 1
- with Text_IO; use Text_IO;
- with Calendar; use Calendar;
-
- procedure Timer is
-
- package Int_IO is new Text_IO.Integer_IO(INTEGER);
- use Int_IO;
- package Fix_IO is new Text_IO.Fixed_IO(DAY_DURATION);
- use Fix_IO;
-
- Year,Month,Day : INTEGER;
- Start,Seconds : DAY_DURATION;
- Time_And_Date : TIME;
-
- begin
-
- Put_Line("Begin 3.14 second delay");
- delay 3.14;
- Put_Line("End of 3.14 second delay");
-
- Time_And_Date := Clock;
- Split(Time_And_Date,Year,Month,Day,Start); -- get starting time
-
- for Index in 1..9 loop
- Put("The date and time are now");
- Time_And_Date := Clock;
- Split(Time_And_Date,Year,Month,Day,Seconds);
- Put(Month,3);
- delay 0.2;
- Put(Day,3);
- delay 0.1;
- Put(Year,5);
- delay 0.1;
- Put(Seconds - Start,8,3,0);
- New_Line;
- delay 0.6;
- end loop;
-
- Put_Line("Begin non-accumulative timing loop here.");
-
- Time_And_Date := Clock;
- Split(Time_And_Date,Year,Month,Day,Start); -- get starting time
- for Index in 1..9 loop
- Time_And_Date := Clock;
- Split(Time_And_Date,Year,Month,Day,Seconds);
- Put("The elapsed time is");
- Put(Seconds - Start,8,3,0);
- New_Line;
- delay DAY_DURATION(Index) - (Seconds - Start);
- end loop;
- end Timer;
-
- -- Result of Execution
-
- -- Begin 3.14 second delay
- -- End of 3.14 second delay
- -- The date and time are now 7 22 1988 0.000
- -- The date and time are now 7 22 1988 1.090
- -- The date and time are now 7 22 1988 2.140
- -- The date and time are now 7 22 1988 3.180
- -- The date and time are now 7 22 1988 4.230
- -- The date and time are now 7 22 1988 5.270
- -- The date and time are now 7 22 1988 6.320
- -- The date and time are now 7 22 1988 7.360
- -- The date and time are now 7 22 1988 8.400
- -- Begin non-accumulative timing loop here
- -- The elapsed time is 0.000
- -- The elapsed time is 1.100
- -- The elapsed time is 2.030
- -- The elapsed time is 3.020
- -- The elapsed time is 4.040
- -- The elapsed time is 5.030
- -- The elapsed time is 6.020
- -- The elapsed time is 7.010
- -- The elapsed time is 8.000
-
-