changeset 415:1c3f42442fba libavcodec

* added simple test main - see comments about how to compile - should be probably made as a regression test
author kabi
date Thu, 23 May 2002 10:09:33 +0000
parents f56e4d08e082
children ca1f2c0e44ef
files i386/dsputil_mmx.c
diffstat 1 files changed, 46 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/i386/dsputil_mmx.c	Wed May 22 23:18:59 2002 +0000
+++ b/i386/dsputil_mmx.c	Thu May 23 10:09:33 2002 +0000
@@ -928,6 +928,7 @@
 static void just_return() { return; }
 #endif
 
+#ifndef TESTCPU_MAIN
 void dsputil_init_mmx(void)
 {
     mm_flags = mm_support();
@@ -952,7 +953,7 @@
         put_pixels_clamped = put_pixels_clamped_mmx;
         add_pixels_clamped = add_pixels_clamped_mmx;
         clear_blocks= clear_blocks_mmx;
-       
+
         pix_abs16x16     = pix_abs16x16_mmx;
         pix_abs16x16_x2  = pix_abs16x16_x2_mmx;
         pix_abs16x16_y2  = pix_abs16x16_y2_mmx;
@@ -972,7 +973,7 @@
         put_no_rnd_pixels_tab[1] = put_no_rnd_pixels_x2_mmx;
         put_no_rnd_pixels_tab[2] = put_no_rnd_pixels_y2_mmx;
         put_no_rnd_pixels_tab[3] = put_no_rnd_pixels_xy2_mmx;
-        
+
         avg_pixels_tab[0] = avg_pixels_mmx;
         avg_pixels_tab[1] = avg_pixels_x2_mmx;
         avg_pixels_tab[2] = avg_pixels_y2_mmx;
@@ -988,7 +989,7 @@
             pix_abs16x16_x2 = pix_abs16x16_x2_mmx2;
             pix_abs16x16_y2 = pix_abs16x16_y2_mmx2;
             pix_abs16x16_xy2= pix_abs16x16_xy2_mmx2;
-            
+
             pix_abs8x8    = pix_abs8x8_mmx2;
             pix_abs8x8_x2 = pix_abs8x8_x2_mmx2;
             pix_abs8x8_y2 = pix_abs8x8_y2_mmx2;
@@ -998,7 +999,7 @@
             put_pixels_tab[2] = put_pixels_y2_mmx2;
             put_no_rnd_pixels_tab[1] = put_no_rnd_pixels_x2_mmx2;
             put_no_rnd_pixels_tab[2] = put_no_rnd_pixels_y2_mmx2;
-            
+
             avg_pixels_tab[0] = avg_pixels_mmx2;
             avg_pixels_tab[1] = avg_pixels_x2_mmx2;
             avg_pixels_tab[2] = avg_pixels_y2_mmx2;
@@ -1080,3 +1081,44 @@
         }
     }
 }
+
+#else // TESTCPU_MAIN
+/*
+ * for testing speed of various routine - should be probably extended
+ * for a general purpose regression test later
+ *
+ * for now use it this way:
+ *
+ * gcc -O4 -fomit-frame-pointer -DHAVE_AV_CONFIG_H -DTESTCPU_MAIN  -I../.. -o test dsputil_mmx.c
+ *
+ * in libavcodec/i386 directory - then run ./test
+ */
+static inline long long rdtsc()
+{
+    long long l;
+    asm volatile(   "rdtsc\n\t"
+		    : "=A" (l)
+		);
+    return l;
+}
+
+int main(int argc, char* argv[])
+{
+    volatile int v;
+    int i;
+    const int linesize = 720;
+    char bu[32768];
+    uint64_t te, ts = rdtsc();
+    char* im = bu;
+    op_pixels_func fc = put_pixels_y2_mmx2;
+    for(i=0; i<1000000; i++){
+	fc(im, im + 1000, linesize, 16);
+	im += 16; //
+	if (im > bu + 10000)
+            im = bu;
+    }
+    te = rdtsc();
+    printf("CPU Ticks: %7d\n", (int)(te - ts));
+    fflush(stdout);
+}
+#endif