ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/liblzf/bench.c
(Generate patch)

Comparing liblzf/bench.c (file contents):
Revision 1.14 by root, Sun Mar 27 23:53:23 2011 UTC vs.
Revision 1.16 by root, Sun Jan 11 01:32:04 2015 UTC

21typedef unsigned long tval; 21typedef unsigned long tval;
22typedef unsigned long long stamp64; 22typedef unsigned long long stamp64;
23 23
24extern inline tval stamp(void) 24extern inline tval stamp(void)
25{ 25{
26 tval tsc; 26 tval tsc; long dummy;
27 asm volatile("rdtsc" : "=a" (tsc) : : "edx"); 27 asm volatile("cpuid; rdtsc" : "=a" (tsc), "=d" (dummy) : "a" (0) : "ebx", "ecx");
28 return tsc; 28 return tsc;
29} 29}
30 30
31extern inline tval measure(tval t) 31extern inline tval measure(tval t)
32{ 32{
33 tval tsc; 33 tval tsc; long dummy;
34 asm volatile("rdtsc" : "=a" (tsc) : : "edx"); 34 asm volatile("cpuid; rdtsc" : "=a" (tsc), "=d" (dummy) : "a" (0) : "ebx", "ecx");
35 if (tsc>t) 35 if (tsc>t)
36 return tsc-t; 36 return tsc-t;
37 else 37 else
38 return t-tsc; 38 return t-tsc;
39} 39}
40 40
41static void sigu (int signum) 41static void sigu (int signum)
42{ 42{
43} 43}
44 44
45#define DSIZE 2821120 45#define DSIZE 17318440
46#define DSIZE 32768 46//#define DSIZE 32768
47
48#include "lzf_c_best.c"
47 49
48unsigned char data[DSIZE], data2[DSIZE*2], data3[DSIZE*2]; 50unsigned char data[DSIZE], data2[DSIZE*2], data3[DSIZE*2];
49 51
50int main(void) 52int main(void)
51{ 53{
52 tval s; 54 tval s;
53 tval si[1000]; 55 tval si[1000];
54 int i, l, j; 56 int i, j, k, l;
55 int min = 1<<30; 57 int min = 1<<30;
56 int lp; 58 int lp;
57 char buf[8192]; 59 char buf[8192];
58 int p[2]; 60 int p[2];
59 long ctr = 1; 61 long ctr = 1;
82 //read (p[0], &buf, 4); 84 //read (p[0], &buf, 4);
83 //stat ("/etc/passwd", &sbuf); 85 //stat ("/etc/passwd", &sbuf);
84 //struct timeval tv; gettimeofday (&tv, 0); 86 //struct timeval tv; gettimeofday (&tv, 0);
85 //void *x = mmap (0, 16384, PROT_READ|PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE,-1,0); 87 //void *x = mmap (0, 16384, PROT_READ|PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE,-1,0);
86 88
87 l = lzf_compress (data, DSIZE, data2, DSIZE*2); 89 l = lzf_compress_best (data, DSIZE, data2, DSIZE*2);
90 //for (k = 0; k < l; ++k)
91 //printf ("1 %2d: %02x\n", k, data2[k]);
88 assert(l); 92 assert(l);
89 93
90 j = lzf_decompress (data2, l, data3, DSIZE*2); 94 j = lzf_decompress (data2, l, data3, DSIZE*2);
95 //for (k = 0; k < j; ++k)
96 //printf ("2 %2d: %02x\n", k, data3[k]);
91 assert (j == DSIZE); 97 assert (j == DSIZE);
92 98
93 si[0]=measure(s); 99 si[0]=measure(s);
94 100
95 assert (!memcmp (data, data3, DSIZE)); 101 assert (!memcmp (data, data3, DSIZE));

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines