home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / programming / ada_1 / Examples_ada_delay_test < prev    next >
Encoding:
Text File  |  1994-08-14  |  1.0 KB  |  45 lines

  1. -- ++
  2. -- Procedure to test the granularity and accuracy of the delay statement.
  3. -- --
  4.  
  5. with Calendar;
  6. with System;
  7. with Text_IO;
  8. procedure Delay_Test is
  9.  
  10. package Fixed_IO is new Text_IO.Fixed_IO ( Duration );
  11.  
  12. Waiter_Priority : constant System.Priority := System.Priority'Last;
  13. task Waiter is
  14.    pragma PRIORITY ( Waiter_Priority );
  15. end Waiter;
  16.  
  17. task body Waiter is
  18.    Cum_Delay : Duration := 0.0;
  19.    The_Delay : constant Duration := 0.57;
  20.    Time : Calendar.Time;
  21.    Count : constant := 10;
  22. use Calendar;   -- for ops on Calendar only
  23. begin
  24.    Time := Calendar.Clock;
  25.    for I in 1 .. Count loop
  26.       delay The_Delay;
  27.    end loop;
  28.    Cum_Delay := (Calendar.Clock - Time);
  29.  
  30.    Text_IO.Put ( "average actual delay = " );
  31.    Fixed_IO.Put ( Cum_Delay / Count );
  32.    Text_IO.Put ( " requested = " );
  33.    Fixed_IO.Put ( The_Delay );
  34.    Text_IO.New_Line;
  35. end Waiter;   
  36.    
  37. begin
  38.  
  39.    Fixed_IO.Put ( Calendar.Seconds ( Calendar.Clock ) );
  40.    Text_IO.New_Line;
  41.    delay 3.3;
  42.    Fixed_IO.Put ( Calendar.Seconds ( Calendar.Clock ) );
  43.    Text_IO.New_Line;
  44.    
  45. end Delay_Test;