[svn] / trunk / xvidcore / examples / xvid_bench.c Repository:
ViewVC logotype

Diff of /trunk/xvidcore/examples/xvid_bench.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 262, Sun Jul 7 09:45:40 2002 UTC revision 898, Wed Feb 26 19:05:20 2003 UTC
# Line 24  Line 24 
24   *  Don't take the checksums and crc too seriouly, they aren't   *  Don't take the checksums and crc too seriouly, they aren't
25   *  bullet-proof (should plug some .md5 here)...   *  bullet-proof (should plug some .md5 here)...
26   *   *
27   *   compiles with something like:   *   compiles best at xvidcore/src-dir with something like
28   *   gcc -o xvid_bench xvid_bench.c  -I../src/ -lxvidcore -lm   *
29     *   gcc -DARCH_IS_IA32 -DARCH_IS_32BIT -o xvid_bench xvid_bench.c  \
30     *        ../build/generic/libxvidcore.a -lm
31   *   *
32   *      History:   *      History:
33   *   *
34   *      06.06.2002  initial coding      -Skal-   *      06.06.2002  initial coding      -Skal-
35     *      27.02.2003  minor changes (compile, sad16v) <gruel@web.de>
36   *   *
37   *************************************************************************/   *************************************************************************/
38    
39  #include <stdio.h>  #include <stdio.h>
40  #include <stdlib.h>  #include <stdlib.h>
 #include <sys/time.h>  // for gettimeofday  
41  #include <string.h>    // for memset  #include <string.h>    // for memset
42  #include <assert.h>  #include <assert.h>
43    
44    #ifndef WIN32
45    #include <sys/time.h>   // for gettimeofday
46    #else
47    #include <time.h>
48    #endif
49    
50    
51  #include "xvid.h"  #include "xvid.h"
52    
53  // inner guts  // inner guts
# Line 56  Line 65 
65  #include "bitstream/cbp.h"  #include "bitstream/cbp.h"
66    
67  #include <math.h>  #include <math.h>
68    
69    #ifndef M_PI
70    #define M_PI            3.14159265358979323846
71    #endif
72    
73  const int speed_ref = 100;  // on slow machines, decrease this value  const int speed_ref = 100;  // on slow machines, decrease this value
74    
75  /*********************************************************************  /*********************************************************************
# Line 65  Line 79 
79   /* returns time in micro-s*/   /* returns time in micro-s*/
80  double gettime_usec()  double gettime_usec()
81  {  {
82    #ifndef WIN32
83    struct timeval  tv;    struct timeval  tv;
84    gettimeofday(&tv, 0);    gettimeofday(&tv, 0);
85    return tv.tv_sec*1.0e6f + tv.tv_usec;    return tv.tv_sec*1.0e6 + tv.tv_usec;
86    #else
87            clock_t clk;
88            clk = clock();
89            return clk * 1000000 / CLOCKS_PER_SEC;
90    #endif
91  }  }
92    
93   /* returns squared deviates (mean(v*v)-mean(v)^2) of a 8x8 block */   /* returns squared deviates (mean(v*v)-mean(v)^2) of a 8x8 block */
# Line 102  Line 122 
122  , { "SSE2  ", XVID_CPU_SSE2 | XVID_CPU_MMX }  , { "SSE2  ", XVID_CPU_SSE2 | XVID_CPU_MMX }
123  , { "3DNOW ", XVID_CPU_3DNOW }  , { "3DNOW ", XVID_CPU_3DNOW }
124  , { "3DNOWE", XVID_CPU_3DNOWEXT }  , { "3DNOWE", XVID_CPU_3DNOWEXT }
125    , { "IA64  ", XVID_CPU_IA64 }
126  //, { "TSC   ", XVID_CPU_TSC }  //, { "TSC   ", XVID_CPU_TSC }
127  , { 0, 0 } }  , { 0, 0 } }
128    
# Line 109  Line 130 
130  { { "PLAINC", 0 }  { { "PLAINC", 0 }
131  , { "MMX   ", XVID_CPU_MMX }  , { "MMX   ", XVID_CPU_MMX }
132  //, { "MMXEXT", XVID_CPU_MMXEXT | XVID_CPU_MMX }  //, { "MMXEXT", XVID_CPU_MMXEXT | XVID_CPU_MMX }
133    , { "IA64  ", XVID_CPU_IA64 }
134  , { 0, 0 } }  , { 0, 0 } }
135    
136  , cpu_short_list2[] =  , cpu_short_list2[] =
# Line 197  Line 219 
219  void test_sad()  void test_sad()
220  {  {
221    const int nb_tests = 2000*speed_ref;    const int nb_tests = 2000*speed_ref;
222    int tst;    int tst,dummy[4];
223    CPU *cpu;    CPU *cpu;
224    int i;    int i;
225    uint8_t Cur[16*16], Ref1[16*16], Ref2[16*16];    uint8_t Cur[16*16], Ref1[16*16], Ref2[16*16];
# Line 226  Line 248 
248    
249      t = gettime_usec();      t = gettime_usec();
250      emms();      emms();
251      for(tst=0; tst<nb_tests; ++tst) s = sad16(Cur, Ref1, 16, -1);      for(tst=0; tst<nb_tests; ++tst) s = sad16(Cur, Ref1, 16, 65535);
252      emms();      emms();
253      t = (gettime_usec() - t) / nb_tests;      t = (gettime_usec() - t) / nb_tests;
254      printf( "%s - sad16   %.3f usec       sad=%d\n", cpu->name, t, s );      printf( "%s - sad16   %.3f usec       sad=%d\n", cpu->name, t, s );
# Line 234  Line 256 
256    
257      t = gettime_usec();      t = gettime_usec();
258      emms();      emms();
259        for(tst=0; tst<nb_tests; ++tst) s = sad16v(Cur, Ref1, 16, dummy);
260        emms();
261        t = (gettime_usec() - t) / nb_tests;
262        printf( "%s - sad16v  %.3f usec       sad=%d\n", cpu->name, t, s );
263        if (s!=27214) printf( "*** CRC ERROR! ***\n" );
264    
265        t = gettime_usec();
266        emms();
267      for(tst=0; tst<nb_tests; ++tst) s = sad16bi(Cur, Ref1, Ref2, 16);      for(tst=0; tst<nb_tests; ++tst) s = sad16bi(Cur, Ref1, Ref2, 16);
268      emms();      emms();
269      t = (gettime_usec() - t) / nb_tests;      t = (gettime_usec() - t) / nb_tests;

Legend:
Removed from v.262  
changed lines
  Added in v.898

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4