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

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines