summaryrefslogtreecommitdiff
path: root/ce/test/rx/general/src/test_speed.c
diff options
context:
space:
mode:
Diffstat (limited to 'ce/test/rx/general/src/test_speed.c')
-rw-r--r--ce/test/rx/general/src/test_speed.c193
1 files changed, 193 insertions, 0 deletions
diff --git a/ce/test/rx/general/src/test_speed.c b/ce/test/rx/general/src/test_speed.c
new file mode 100644
index 0000000000..210b082cc3
--- /dev/null
+++ b/ce/test/rx/general/src/test_speed.c
@@ -0,0 +1,193 @@
+/* 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 "ce/inc/frame_measurement.h"
+#include "mac/common/tonemap.h"
+#include "ce/test/common/print_utils.h"
+#include "lib/bitstream.h"
+#define RXCE
+#include "ce/inc/cei.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 [nothing] %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)));
+
+ uint word = 0x76543210;
+ uint i, test;
+ int nibble;
+ bitstream_t stream_writer;
+ gettimeofday (&tv0, NULL);
+ gettimeofday (&tv1, NULL);
+ printf ("getitmeofday duration %d\n",(int) (tv1.tv_usec - tv0.tv_usec));
+ gettimeofday (&tv0, NULL);
+ for (test=0; test<1000; test++)
+ {
+ word = 0;
+ for (i=0; i<8; i++)
+ {
+ nibble = i+1;
+ word = (word >> 4) | (nibble << 28);
+ }
+ }
+ gettimeofday (&tv1, NULL);
+ printf ("nibble to u32 duration test1 %d /1000\n",(int) (tv1.tv_usec - tv0.tv_usec));
+
+ gettimeofday (&tv0, NULL);
+ for (test=0; test<1000; test++)
+ {
+ word = 0;
+ for (i=0; i<8; i++)
+ {
+ nibble = i+1;
+ word = word | (nibble << (i<<2));
+ }
+ }
+ gettimeofday (&tv1, NULL);
+ printf ("nibble to u32 duration test2 %d /1000\n",(int) (tv1.tv_usec - tv0.tv_usec));
+
+ frame_measurement_init ();
+
+ uint noise = 0;
+ gettimeofday (&tv0, NULL);
+ update_threshold (1, 1);
+ for (i=0; i<1536; i++)
+ {
+ noise2mod (noise);
+ }
+ gettimeofday (&tv1, NULL);
+ printf ("noise2mod duration --worst : %d\n",(int) (tv1.tv_usec - tv0.tv_usec));
+
+ noise = 10000;
+ gettimeofday (&tv0, NULL);
+ update_threshold (1, 1);
+ for (i=0; i<1536; i++)
+ {
+ noise2mod (noise);
+
+ }
+ gettimeofday (&tv1, NULL);
+ printf ("noise2mod duration --best : %d\n",(int) (tv1.tv_usec - tv0.tv_usec));
+
+
+ gettimeofday (&tv0, NULL);
+ blk_t *blk = blk_alloc_desc ();
+ gettimeofday (&tv1, NULL);
+ printf ("first blk allocation duration : %d\n",(int) (tv1.tv_usec - tv0.tv_usec));
+ blk_release_desc (blk);
+ gettimeofday (&tv0, NULL);
+ blk = blk_alloc_desc ();
+ gettimeofday (&tv1, NULL);
+ printf ("second blk allocation duration : %d\n",(int) (tv1.tv_usec - tv0.tv_usec));
+ blk_release_desc (blk);
+
+ blk_t *blk_last;
+ gettimeofday (&tv0, NULL);
+ blk_t *blk_first = blk_alloc_desc_range (10, &blk_last);
+ gettimeofday (&tv1, NULL);
+ printf ("multi-blk allocation duration (10) : %d\n",(int) (tv1.tv_usec - tv0.tv_usec));
+ blk_release_desc_range (blk_first, blk_last);
+
+
+ phy_chandata_t *last, *browser;
+ phy_chandata_t *first = (phy_chandata_t *) blk_alloc_desc_range (PHY_CHANDATA_NRJ_BLK_NB, (blk_t **) &last);
+ last->last = 1;
+ last->blk.next = NULL;
+ browser = first;
+ noise = 0;
+ int j, k=0;
+ u32 * data = (u32 * ) browser->blk.data;
+ for (i=0; i<PHY_CHANDATA_NRJ_BLK_NB; i++)
+ {
+ for (j=0; j<BLK_SIZE/4; j++)
+ {
+ data[j] = (THR3[1][k%7]) | ((THR3[1][(k+1)%7])<<16);
+ k+=2;
+ }
+ browser = (phy_chandata_t *) (browser->blk.next);
+ if (browser) data = (u32 * ) browser->blk.data;
+ }
+ tonemap_t *worst_tonemap = NULL;
+ gettimeofday (&tv0, NULL);
+ compute_worst_tonemap (&worst_tonemap, first);
+ gettimeofday (&tv1, NULL);
+ printf ("default tonemap computation duration : %d\n",(int) (tv1.tv_usec - tv0.tv_usec));
+ ce_print_tonemap (worst_tonemap);
+ blk_release_desc_range ((blk_t *) first, (blk_t *)last);
+
+ u8 buf[1536];
+ for (i=0; i<1536; i++) buf[i] = 0x00;
+ u8 mask[(PHY_CARRIER_NB+7)/8];
+ for (i=0; i<(PHY_CARRIER_NB+7)/8; i++) mask[i] = 0xFF;
+ mask[i-1] = ((1<<(PHY_CARRIER_NB%8))-1);
+ uint entry_nb;
+ gettimeofday (&tv0, NULL);
+ for (test=0; test<100; test++)
+ {
+ bitstream_init (&stream_writer, buf, 1518, BITSTREAM_WRITE);
+ entry_nb = cei_encode_tm (&stream_writer, worst_tonemap->tmdma_desc_head, mask);
+ }
+ gettimeofday (&tv1, NULL);
+ printf ("cei building duration : %d\n",(int) (tv1.tv_usec - tv0.tv_usec));
+
+ tonemap_free (worst_tonemap);
+ return 0;
+}
+