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

Comparing liblzf/bench.c (file contents):
Revision 1.4 by root, Tue Nov 13 10:48:02 2007 UTC vs.
Revision 1.8 by root, Tue May 6 22:49:18 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 <signal.h>
11#include <X11/Xlib.h>
4 12
5#include "lzf.h" 13#include "lzf.h"
6//#include "fastlz.c" 14//#include "fastlz.c"
7 15
8typedef unsigned long tval; 16typedef unsigned long tval;
23 return tsc-t; 31 return tsc-t;
24 else 32 else
25 return t-tsc; 33 return t-tsc;
26} 34}
27 35
36static void sigu (int signum)
37{
38}
39
40int eventfd(unsigned int,int);
41
28#define DSIZE 2821120 42#define DSIZE 2821120
29 43
30unsigned char data[DSIZE], data2[DSIZE*2], data3[DSIZE*2]; 44unsigned char data[DSIZE], data2[DSIZE*2], data3[DSIZE*2];
31 45
32int main(void) 46int main(void)
34 tval s; 48 tval s;
35 tval si[1000]; 49 tval si[1000];
36 int i, l, j; 50 int i, l, j;
37 int min = 1<<30; 51 int min = 1<<30;
38 int lp; 52 int lp;
53 char buf[8192];
54 int p[2];
55 int evfd = eventfd (0, 0);
56 long ctr = 1;
57
58 pipe (p);
39 59
40 FILE *f = fopen ("data", "r"); 60 FILE *f = fopen ("data", "r");
41 fread (data, DSIZE, 1, f); 61 fread (data, DSIZE, 1, f);
42 fclose (f); 62 fclose (f);
43 63
64 signal (SIGURG, sigu);
65
44 for (lp = 0; lp < 1000; lp++) { 66 for (lp = 0; lp < 100000; lp++) {
45 s=stamp(); 67 s=stamp();
46 l = lzf_compress (data, DSIZE, data2, DSIZE*2); 68
47 //l = fastlz_compress_level (1, data, DSIZE, data2); 69 snprintf (buf, 64, "<1.%llx>", (unsigned long long)0xa234567812ULL);
70 //kill (0, SIGURG);
71 //write (evfd, &ctr, 8);
72 //read (evfd, &ctr, 8);
73// write (p[1], &buf, 1);
74// read (p[0], &buf, 4);
75
48 si[0]=measure(s); 76 si[0]=measure(s);
77
49 j = lzf_decompress (data2, l, data3, DSIZE*2); 78 //j = lzf_decompress (data2, l, data3, DSIZE*2);
50 79
51 printf ("\r%10d (%d) ", si[0], l); 80 printf ("\r%10d (%d) ", si[0], l);
52 if (si[0] < min && si[0] > 0) 81 if (si[0] < min && si[0] > 0)
53 { 82 {
54 printf ("\n"); 83 printf ("\n");
55 min = si[0]; 84 min = si[0];
56 } 85 }
57 86
58 fflush (stdout); 87 fflush (stdout);
59 88
60 assert (memcmp (data, data3, DSIZE) == 0); 89 //assert (memcmp (data, data3, DSIZE) == 0);
61 } 90 }
62 return 0; 91 return 0;
63} 92}
64 93
65 94

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines