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

Comparing liblzf/bench.c (file contents):
Revision 1.3 by root, Tue Mar 8 19:59:52 2005 UTC vs.
Revision 1.7 by root, Fri Feb 8 13:20:26 2008 UTC

1#include <stdio.h> 1#include <stdio.h>
2#include <assert.h> 2#include <assert.h>
3#include <string.h> 3#include <string.h>
4#include <time.h>
5#include <sys/time.h>
6#include <sys/types.h>
7#include <sys/socket.h>
8#include <sys/ioctl.h>
9#include <math.h>
10#include <X11/Xlib.h>
4 11
5#include "lzf.h" 12#include "lzf.h"
13//#include "fastlz.c"
6 14
7typedef unsigned long tval; 15typedef unsigned long tval;
8typedef unsigned long long stamp64; 16typedef unsigned long long stamp64;
9 17
10extern inline tval stamp(void) 18extern inline tval stamp(void)
22 return tsc-t; 30 return tsc-t;
23 else 31 else
24 return t-tsc; 32 return t-tsc;
25} 33}
26 34
27#define DSIZE 1000000 35#define DSIZE 2821120
28 36
29unsigned char data[DSIZE], data2[DSIZE*2], data3[DSIZE*2]; 37unsigned char data[DSIZE], data2[DSIZE*2], data3[DSIZE*2];
30 38
31int main(void) 39int main(void)
32{ 40{
33 tval s; 41 tval s;
34 tval si[1000]; 42 tval si[1000];
35 int i, l, j; 43 int i, l, j;
36 int min = 1<<30; 44 int min = 1<<30;
37 int lp; 45 int lp;
46 char buf[8192];
47 int p[2];
48
49 pipe (p);
38 50
39 FILE *f = fopen ("data", "r"); 51 FILE *f = fopen ("data", "r");
40 fread (data, DSIZE, 1, f); 52 fread (data, DSIZE, 1, f);
41 fclose (f); 53 fclose (f);
42 54
43 for (lp = 0; lp < 1000; lp++) { 55 for (lp = 0; lp < 100000; lp++) {
44 s=stamp(); 56 s=stamp();
45 l = lzf_compress (data, DSIZE, data2, DSIZE*2); 57
46 j = lzf_decompress (data2, l, data3, DSIZE*2); 58 kill (0, 23);
59// write (p[1], &p, 1);
60// read (p[1], &i, 4);
61
47 si[0]=measure(s); 62 si[0]=measure(s);
63
64 //j = lzf_decompress (data2, l, data3, DSIZE*2);
48 65
49 printf ("\r%10d (%d) ", si[0], l); 66 printf ("\r%10d (%d) ", si[0], l);
50 if (si[0] < min && si[0] > 0) 67 if (si[0] < min && si[0] > 0)
51 { 68 {
52 printf ("\n"); 69 printf ("\n");
53 min = si[0]; 70 min = si[0];
54 } 71 }
55 72
56 fflush (stdout); 73 fflush (stdout);
57 74
58 assert (memcmp (data, data3, DSIZE) == 0); 75 //assert (memcmp (data, data3, DSIZE) == 0);
59 } 76 }
60 return 0; 77 return 0;
61} 78}
62 79
63 80

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines