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

Comparing cvsroot/liblzf/bench.c (file contents):
Revision 1.7 by root, Fri Feb 8 13:20:26 2008 UTC vs.
Revision 1.11 by root, Sat Jul 18 05:59:21 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> 4#include <time.h>
5#include <sys/time.h> 5#include <sys/time.h>
6#include <sys/times.h>
6#include <sys/types.h> 7#include <sys/types.h>
7#include <sys/socket.h> 8#include <sys/socket.h>
8#include <sys/ioctl.h> 9#include <sys/ioctl.h>
10#include <sys/stat.h>
11#include <sys/resource.h>
9#include <math.h> 12#include <math.h>
13#include <signal.h>
10#include <X11/Xlib.h> 14#include <X11/Xlib.h>
11 15
12#include "lzf.h" 16#include "lzf.h"
13//#include "fastlz.c" 17//#include "fastlz.c"
14 18
30 return tsc-t; 34 return tsc-t;
31 else 35 else
32 return t-tsc; 36 return t-tsc;
33} 37}
34 38
39static void sigu (int signum)
40{
41}
42
43int eventfd(unsigned int,int);
44
35#define DSIZE 2821120 45#define DSIZE 2821120
36 46
37unsigned char data[DSIZE], data2[DSIZE*2], data3[DSIZE*2]; 47unsigned char data[DSIZE], data2[DSIZE*2], data3[DSIZE*2];
38 48
39int main(void) 49int main(void)
43 int i, l, j; 53 int i, l, j;
44 int min = 1<<30; 54 int min = 1<<30;
45 int lp; 55 int lp;
46 char buf[8192]; 56 char buf[8192];
47 int p[2]; 57 int p[2];
58 int evfd = eventfd (0, 0);
59 long ctr = 1;
60 struct stat sbuf;
48 61
49 pipe (p); 62 pipe (p);
50 63
51 FILE *f = fopen ("data", "r"); 64 FILE *f = fopen ("data", "r");
52 fread (data, DSIZE, 1, f); 65 fread (data, DSIZE, 1, f);
53 fclose (f); 66 fclose (f);
54 67
68 signal (SIGURG, sigu);
69
55 for (lp = 0; lp < 100000; lp++) { 70 for (lp = 0; lp < 1000000; lp++) {
56 s=stamp(); 71 s=stamp();
57 72
73 struct timespec ts; clock_gettime (CLOCK_THREAD_CPUTIME_ID, &ts);
74 //printf ("%9ld\n", ts.tv_nsec);//D
75 //struct rusage usage; getrusage (RUSAGE_SELF, &usage);
76 //struct tms tms; times (&tms);
77
58 kill (0, 23); 78 //kill (0, SIGURG);
59// write (p[1], &p, 1); 79 //write (evfd, &ctr, 8);
60// read (p[1], &i, 4); 80 //read (evfd, &ctr, 8);
81 //write (p[1], &buf, 1);
82 //read (p[0], &buf, 4);
83 //stat ("/etc/passwd", &sbuf);
84 //struct timeval tv; gettimeofday (&tv, 0);
85
86 //l = lzf_compress (data, DSIZE, data2, DSIZE*2);
87 //assert(l);
61 88
62 si[0]=measure(s); 89 si[0]=measure(s);
63 90
64 //j = lzf_decompress (data2, l, data3, DSIZE*2); 91 //j = lzf_decompress (data2, l, data3, DSIZE*2);
92 //assert (j == DSIZE);
65 93
66 printf ("\r%10d (%d) ", si[0], l); 94 printf ("\r%10d (%d) ", si[0], l);
67 if (si[0] < min && si[0] > 0) 95 if (si[0] < min && si[0] > 0)
68 { 96 {
69 printf ("\n"); 97 printf ("\n");

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines