diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2007-09-27 14:42:22 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2007-09-27 14:42:22 +0000 |
commit | f27b2510f8789b2a5c99abe3f5007016bbe23211 (patch) | |
tree | 9e185bb16ec0f7e0d779345766bfbb024a549451 /delay_until | |
parent | 67e0556fd04f524bc35ba5c560d1aec5e82850c0 (diff) |
2007-09-27 Joel Sherrill <joel.sherrill@oarcorp.com>
* .cvsiginore, ChangeLog, Makefile, README, delay_until.adb: New files.
Diffstat (limited to 'delay_until')
-rw-r--r-- | delay_until/.cvsiginore | 5 | ||||
-rw-r--r-- | delay_until/ChangeLog | 4 | ||||
-rw-r--r-- | delay_until/Makefile | 25 | ||||
-rw-r--r-- | delay_until/README | 9 | ||||
-rw-r--r-- | delay_until/delay_until.adb | 41 |
5 files changed, 84 insertions, 0 deletions
diff --git a/delay_until/.cvsiginore b/delay_until/.cvsiginore new file mode 100644 index 0000000..cf1b678 --- /dev/null +++ b/delay_until/.cvsiginore @@ -0,0 +1,5 @@ +b~hello.adb +b~hello.ads +b~hello.ali +hello +hello.ali diff --git a/delay_until/ChangeLog b/delay_until/ChangeLog new file mode 100644 index 0000000..f863aba --- /dev/null +++ b/delay_until/ChangeLog @@ -0,0 +1,4 @@ +2007-09-27 Joel Sherrill <joel.sherrill@oarcorp.com> + + * .cvsiginore, ChangeLog, Makefile, README, delay_until.adb: New files. + diff --git a/delay_until/Makefile b/delay_until/Makefile new file mode 100644 index 0000000..4e62c18 --- /dev/null +++ b/delay_until/Makefile @@ -0,0 +1,25 @@ +# +# Makefile for Ada Delay Until Benchmark +# +# See README.Makefiles in the main ada-examples directory. +# + +PROGRAM=delay_until + +include $(RTEMS_MAKEFILE_PATH)/Makefile.inc +include $(RTEMS_CUSTOM) +include $(PROJECT_ROOT)/make/leaf.cfg + +# stack size for the first Ada thread +CFLAGS +=-DGNAT_MAIN_STACKSPACE=100 + +# initialize the network stack -- assumes existence of networkconfig.h +# CFLAGS +=-DMAIN_USE_NETWORKING=1 + +# Should we prompt for command line arguments? +# DEFINES +=-DMAIN_USE_REQUIRES_COMMAND_LINE + +# If you want to hard-code the command line, define this to a string +# DEFINES += -DMAIN_COMMAND_LINE="ARGS" + +include ../Makefile.shared diff --git a/delay_until/README b/delay_until/README new file mode 100644 index 0000000..276ad81 --- /dev/null +++ b/delay_until/README @@ -0,0 +1,9 @@ +# +# $Id$ +# + +This directory contains a Ada example program with a delay until. + +See the README.Makefiles in the top directory for instructions +on building for most BSPs. + diff --git a/delay_until/delay_until.adb b/delay_until/delay_until.adb new file mode 100644 index 0000000..8253c52 --- /dev/null +++ b/delay_until/delay_until.adb @@ -0,0 +1,41 @@ +with Ada.Real_Time; +with Ada.Text_Io; + +use type Ada.Real_Time.Time; +use type Ada.Real_Time.Time_Span; + + +procedure Delay_Until_Test is + Next_Wakeup : Ada.Real_Time.Time; + Period : constant Ada.Real_Time.Time_Span := Ada.Real_Time.Nanoseconds (16666667); +-- Period : constant Ada.Real_Time.Time_Span := Ada.Real_Time.Nanoseconds (20000); + + Iterations : constant := 1000; + Actual_Span : array (1..Iterations) of Ada.Real_Time.Time_Span; + Average_Span : Ada.Real_Time.Time_Span := Ada.Real_Time.Time_Span_Zero; + Max_Span : Ada.Real_Time.Time_Span := Ada.Real_Time.Time_Span_First; + Min_Span : Ada.Real_Time.Time_Span := Ada.Real_Time.Time_Span_Last; + +begin + Ada.Text_Io.Put_Line (Integer'Image (Iterations) & " iterations with " & + Duration'Image (Ada.Real_Time.To_Duration(Period)) & "s period"); + Next_Wakeup := Ada.Real_Time.Clock + Period; + for Count in 1..Iterations loop + delay until Next_Wakeup; + + Actual_Span (Count) := Ada.Real_Time.Clock - (Next_Wakeup - Period); + Average_Span := Average_Span + (Actual_Span (Count) / Iterations); + if Actual_Span (Count) > Max_Span then + Max_Span := Actual_Span (Count); + end if; + if Actual_Span (Count) < Min_Span then + Min_Span := Actual_Span (Count); + end if; + + Next_Wakeup := Next_Wakeup + Period; + end loop; + + Ada.Text_Io.Put_Line ("Average delay is" & Duration'Image (Ada.Real_Time.To_Duration (Average_Span)) & "s"); + Ada.Text_Io.Put_Line ("Maximum delay is" & Duration'Image (Ada.Real_Time.To_Duration (Max_Span)) & "s"); + Ada.Text_Io.Put_Line ("Minimum delay is" & Duration'Image (Ada.Real_Time.To_Duration (Min_Span)) & "s"); +end Delay_Until_Test; |