ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/liblzf/bench.c
Revision: 1.6
Committed: Tue Nov 13 11:41:46 2007 UTC (16 years, 6 months ago) by root
Content type: text/plain
Branch: MAIN
CVS Tags: rel-3_1, rel-3_0
Changes since 1.5: +2 -2 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.1 #include <stdio.h>
2     #include <assert.h>
3     #include <string.h>
4    
5     #include "lzf.h"
6 root 1.4 //#include "fastlz.c"
7 root 1.1
8     typedef unsigned long tval;
9     typedef unsigned long long stamp64;
10    
11     extern inline tval stamp(void)
12     {
13     tval tsc;
14     asm volatile("rdtsc" : "=a" (tsc) : : "edx");
15     return tsc;
16     }
17    
18     extern inline tval measure(tval t)
19     {
20     tval tsc;
21     asm volatile("rdtsc" : "=a" (tsc) : : "edx");
22     if (tsc>t)
23     return tsc-t;
24     else
25     return t-tsc;
26     }
27    
28 root 1.4 #define DSIZE 2821120
29 root 1.1
30     unsigned char data[DSIZE], data2[DSIZE*2], data3[DSIZE*2];
31    
32     int main(void)
33     {
34     tval s;
35     tval si[1000];
36     int i, l, j;
37     int min = 1<<30;
38 root 1.2 int lp;
39 root 1.1
40     FILE *f = fopen ("data", "r");
41     fread (data, DSIZE, 1, f);
42     fclose (f);
43    
44 root 1.3 for (lp = 0; lp < 1000; lp++) {
45 root 1.6 s=stamp();
46 root 1.5 l = lzf_compress (data, DSIZE, data2, DSIZE*2);
47 root 1.4 //l = fastlz_compress_level (1, data, DSIZE, data2);
48 root 1.6 si[0]=measure(s);
49 root 1.5 j = lzf_decompress (data2, l, data3, DSIZE*2);
50 root 1.1
51     printf ("\r%10d (%d) ", si[0], l);
52     if (si[0] < min && si[0] > 0)
53     {
54     printf ("\n");
55     min = si[0];
56     }
57    
58     fflush (stdout);
59    
60     assert (memcmp (data, data3, DSIZE) == 0);
61     }
62     return 0;
63     }
64    
65    
66