summaryrefslogtreecommitdiff
path: root/cesar/test_general/proto_gaisler/src/test_speed.c
diff options
context:
space:
mode:
Diffstat (limited to 'cesar/test_general/proto_gaisler/src/test_speed.c')
-rw-r--r--cesar/test_general/proto_gaisler/src/test_speed.c68
1 files changed, 68 insertions, 0 deletions
diff --git a/cesar/test_general/proto_gaisler/src/test_speed.c b/cesar/test_general/proto_gaisler/src/test_speed.c
new file mode 100644
index 0000000000..aa9242b6fb
--- /dev/null
+++ b/cesar/test_general/proto_gaisler/src/test_speed.c
@@ -0,0 +1,68 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file ./src/test_speed.c
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+
+#include "common/std.h"
+#include "sys/time.h"
+#include "stdio.h"
+#include "string.h"
+#include "math.h"
+
+
+int
+main (int argc, char **argv)
+{
+ struct timeval tv0, tv1;
+ double test_d;
+ int r;
+ double flottant = 0.123456789;
+ double res = flottant;
+ double x=0;
+
+ gettimeofday (&tv0, NULL);
+ for (r=-10000; r<10000; r++)
+ {
+ x = (double)(M_PI*r)/ 10000.0;
+ for (test_d=0; test_d<100; test_d++)
+ {
+ res = test_d * x;
+ }
+ }
+ gettimeofday (&tv1, NULL);
+ printf ("test duration [mux] %d \n", (int) ((tv1.tv_sec*1000000+tv1.tv_usec)-(tv0.tv_sec*1000000 + tv0.tv_usec)));
+ gettimeofday (&tv0, NULL);
+ for (r=-10000; r<10000; r++)
+ {
+ x = (double)(M_PI*r)/ 10000.0;
+ for (test_d=0; test_d<100; test_d++)
+ {
+ res = test_d / x;
+ }
+ }
+ gettimeofday (&tv1, NULL);
+ printf ("test duration [div : dble/dble] %d \n", (int) ((tv1.tv_sec*1000000+tv1.tv_usec)-(tv0.tv_sec*1000000 + tv0.tv_usec)));
+ gettimeofday (&tv0, NULL);
+ for (r=-10000; r<10000; r++)
+ {
+ x = (double)(M_PI*r)/ 10000.0;
+ for (test_d=0; test_d<100; test_d++)
+ {
+ res = sin (x);
+ }
+ }
+ gettimeofday (&tv1, NULL);
+ printf ("test duration [sin (dble)] %d \n", (int) ((tv1.tv_sec*1000000+tv1.tv_usec)-(tv0.tv_sec*1000000 + tv0.tv_usec)));
+ return 0;
+}
+