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.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"
14//#include "fastlz.c"
6 15
7typedef unsigned long tval; 16typedef unsigned long tval;
8typedef unsigned long long stamp64; 17typedef unsigned long long stamp64;
9 18
10extern inline tval stamp(void) 19extern inline tval stamp(void)
22 return tsc-t; 31 return tsc-t;
23 else 32 else
24 return t-tsc; 33 return t-tsc;
25} 34}
26 35
36static void sigu (int signum)
37{
38}
39
40int eventfd(unsigned int,int);
41
27#define DSIZE 1000000 42#define DSIZE 2821120
28 43
29unsigned char data[DSIZE], data2[DSIZE*2], data3[DSIZE*2]; 44unsigned char data[DSIZE], data2[DSIZE*2], data3[DSIZE*2];
30 45
31int main(void) 46int main(void)
32{ 47{
33 tval s; 48 tval s;
34 tval si[1000]; 49 tval si[1000];
35 int i, l, j; 50 int i, l, j;
36 int min = 1<<30; 51 int min = 1<<30;
37 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);
38 59
39 FILE *f = fopen ("data", "r"); 60 FILE *f = fopen ("data", "r");
40 fread (data, DSIZE, 1, f); 61 fread (data, DSIZE, 1, f);
41 fclose (f); 62 fclose (f);
42 63
64 signal (SIGURG, sigu);
65
43 for (lp = 0; lp < 1000; lp++) { 66 for (lp = 0; lp < 100000; lp++) {
44 s=stamp(); 67 s=stamp();
45 l = lzf_compress (data, DSIZE, data2, DSIZE*2); 68
46 j = lzf_decompress (data2, l, data3, DSIZE*2); 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
47 si[0]=measure(s); 76 si[0]=measure(s);
77
78 //j = lzf_decompress (data2, l, data3, DSIZE*2);
48 79
49 printf ("\r%10d (%d) ", si[0], l); 80 printf ("\r%10d (%d) ", si[0], l);
50 if (si[0] < min && si[0] > 0) 81 if (si[0] < min && si[0] > 0)
51 { 82 {
52 printf ("\n"); 83 printf ("\n");
53 min = si[0]; 84 min = si[0];
54 } 85 }
55 86
56 fflush (stdout); 87 fflush (stdout);
57 88
58 assert (memcmp (data, data3, DSIZE) == 0); 89 //assert (memcmp (data, data3, DSIZE) == 0);
59 } 90 }
60 return 0; 91 return 0;
61} 92}
62 93
63 94

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines