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

Comparing liblzf/bench.c (file contents):
Revision 1.9 by root, Thu Dec 18 16:05:14 2008 UTC vs.
Revision 1.13 by root, Tue Jun 1 01:15:34 2010 UTC

1#include <stdio.h> 1#include <stdio.h>
2#include <unistd.h>
2#include <assert.h> 3#include <assert.h>
3#include <string.h> 4#include <string.h>
4#include <time.h> 5#include <time.h>
5#include <sys/time.h> 6#include <sys/time.h>
7#include <sys/times.h>
6#include <sys/types.h> 8#include <sys/types.h>
7#include <sys/socket.h> 9#include <sys/socket.h>
10#include <sys/mman.h>
8#include <sys/ioctl.h> 11#include <sys/ioctl.h>
9#include <sys/stat.h> 12#include <sys/stat.h>
13#include <sys/resource.h>
10#include <math.h> 14#include <math.h>
11#include <signal.h> 15#include <signal.h>
12#include <X11/Xlib.h> 16#include <X11/Xlib.h>
13 17
14#include "lzf.h" 18#include "lzf.h"
36 40
37static void sigu (int signum) 41static void sigu (int signum)
38{ 42{
39} 43}
40 44
41int eventfd(unsigned int,int);
42
43#define DSIZE 2821120 45#define DSIZE 2821120
44 46
45unsigned char data[DSIZE], data2[DSIZE*2], data3[DSIZE*2]; 47unsigned char data[DSIZE], data2[DSIZE*2], data3[DSIZE*2];
46 48
47int main(void) 49int main(void)
51 int i, l, j; 53 int i, l, j;
52 int min = 1<<30; 54 int min = 1<<30;
53 int lp; 55 int lp;
54 char buf[8192]; 56 char buf[8192];
55 int p[2]; 57 int p[2];
56 int evfd = eventfd (0, 0);
57 long ctr = 1; 58 long ctr = 1;
58 struct stat sbuf; 59 struct stat sbuf;
59 60
60 pipe (p); 61 pipe (p);
61 62
63 fread (data, DSIZE, 1, f); 64 fread (data, DSIZE, 1, f);
64 fclose (f); 65 fclose (f);
65 66
66 signal (SIGURG, sigu); 67 signal (SIGURG, sigu);
67 68
68 for (lp = 0; lp < 100000; lp++) { 69 for (lp = 0; lp < 1000000; lp++) {
69 s=stamp(); 70 s=stamp();
70 71
71 //snprintf (buf, 64, "<1.%llx>", (unsigned long long)0xa234567812ULL); 72 //struct timespec ts; clock_gettime (CLOCK_THREAD_CPUTIME_ID, &ts);
72 //getpgrp(); 73 //printf ("%9ld\n", ts.tv_nsec);//D
74 //struct rusage usage; getrusage (RUSAGE_SELF, &usage);
75 //struct tms tms; times (&tms);
76
73 //kill (0, SIGURG); 77 //kill (0, SIGURG);
74 //write (evfd, &ctr, 8); 78 //write (evfd, &ctr, 8);
75 //read (evfd, &ctr, 8); 79 //read (evfd, &ctr, 8);
76 //write (p[1], &buf, 1); 80 //write (p[1], &buf, 1);
77 //read (p[0], &buf, 4); 81 //read (p[0], &buf, 4);
78 //stat ("/etc/passwd", &sbuf); 82 //stat ("/etc/passwd", &sbuf);
79 free(malloc(8*1024*1024)); 83 //struct timeval tv; gettimeofday (&tv, 0);
84 //void *x = mmap (0, 16384, PROT_READ|PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE,-1,0);
85
86 l = lzf_compress (data, DSIZE, data2, DSIZE*2);
87 assert(l);
88
89 j = lzf_decompress (data2, l, data3, DSIZE*2);
90 assert (j == DSIZE);
80 91
81 si[0]=measure(s); 92 si[0]=measure(s);
82 93
83 //j = lzf_decompress (data2, l, data3, DSIZE*2); 94 assert (!memcmp (data, data3, DSIZE));
84 95
85 printf ("\r%10d (%d) ", si[0], l); 96 printf ("\r%10d (%d) ", si[0], l);
86 if (si[0] < min && si[0] > 0) 97 if (si[0] < min && si[0] > 0)
87 { 98 {
88 printf ("\n"); 99 printf ("\n");

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines