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

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines