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 | |
7 | typedef unsigned long tval; |
17 | typedef unsigned long tval; |
8 | typedef unsigned long long stamp64; |
18 | typedef unsigned long long stamp64; |
9 | |
19 | |
10 | extern inline tval stamp(void) |
20 | extern 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 | |
|
|
37 | static void sigu (int signum) |
|
|
38 | { |
|
|
39 | } |
|
|
40 | |
|
|
41 | int eventfd(unsigned int,int); |
|
|
42 | |
27 | #define DSIZE 1000000 |
43 | #define DSIZE 2821120 |
28 | |
44 | |
29 | unsigned char data[DSIZE], data2[DSIZE*2], data3[DSIZE*2]; |
45 | unsigned char data[DSIZE], data2[DSIZE*2], data3[DSIZE*2]; |
30 | |
46 | |
31 | int main(void) |
47 | int 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; |
|
|
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); |
37 | |
61 | |
38 | FILE *f = fopen ("data", "r"); |
62 | FILE *f = fopen ("data", "r"); |
39 | fread (data, DSIZE, 1, f); |
63 | fread (data, DSIZE, 1, f); |
40 | fclose (f); |
64 | fclose (f); |
41 | |
65 | |
42 | for(;;) { |
66 | signal (SIGURG, sigu); |
|
|
67 | |
|
|
68 | for (lp = 0; lp < 100000; lp++) { |
43 | s=stamp(); |
69 | s=stamp(); |
44 | l = lzf_compress (data, DSIZE, data2, DSIZE*2); |
70 | |
45 | j = lzf_decompress (data2, l, data3, DSIZE*2); |
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 | free(malloc(8*1024*1024)); |
|
|
80 | |
46 | si[0]=measure(s); |
81 | si[0]=measure(s); |
|
|
82 | |
|
|
83 | //j = lzf_decompress (data2, l, data3, DSIZE*2); |
47 | |
84 | |
48 | printf ("\r%10d (%d) ", si[0], l); |
85 | printf ("\r%10d (%d) ", si[0], l); |
49 | if (si[0] < min && si[0] > 0) |
86 | if (si[0] < min && si[0] > 0) |
50 | { |
87 | { |
51 | printf ("\n"); |
88 | printf ("\n"); |
52 | min = si[0]; |
89 | min = si[0]; |
53 | } |
90 | } |
54 | |
91 | |
55 | fflush (stdout); |
92 | fflush (stdout); |
56 | |
93 | |
57 | assert (memcmp (data, data3, DSIZE) == 0); |
94 | //assert (memcmp (data, data3, DSIZE) == 0); |
58 | } |
95 | } |
59 | return 0; |
96 | return 0; |
60 | } |
97 | } |
61 | |
98 | |
62 | |
99 | |