| 1 |
root |
1.1 |
#include <stdio.h> |
| 2 |
|
|
#include <assert.h> |
| 3 |
|
|
#include <string.h> |
| 4 |
root |
1.7 |
#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 <math.h> |
| 10 |
root |
1.8 |
#include <signal.h> |
| 11 |
root |
1.7 |
#include <X11/Xlib.h> |
| 12 |
root |
1.1 |
|
| 13 |
|
|
#include "lzf.h" |
| 14 |
root |
1.4 |
//#include "fastlz.c" |
| 15 |
root |
1.1 |
|
| 16 |
|
|
typedef unsigned long tval; |
| 17 |
|
|
typedef unsigned long long stamp64; |
| 18 |
|
|
|
| 19 |
|
|
extern inline tval stamp(void) |
| 20 |
|
|
{ |
| 21 |
|
|
tval tsc; |
| 22 |
|
|
asm volatile("rdtsc" : "=a" (tsc) : : "edx"); |
| 23 |
|
|
return tsc; |
| 24 |
|
|
} |
| 25 |
|
|
|
| 26 |
|
|
extern inline tval measure(tval t) |
| 27 |
|
|
{ |
| 28 |
|
|
tval tsc; |
| 29 |
|
|
asm volatile("rdtsc" : "=a" (tsc) : : "edx"); |
| 30 |
|
|
if (tsc>t) |
| 31 |
|
|
return tsc-t; |
| 32 |
|
|
else |
| 33 |
|
|
return t-tsc; |
| 34 |
|
|
} |
| 35 |
|
|
|
| 36 |
root |
1.8 |
static void sigu (int signum) |
| 37 |
|
|
{ |
| 38 |
|
|
} |
| 39 |
|
|
|
| 40 |
|
|
int eventfd(unsigned int,int); |
| 41 |
|
|
|
| 42 |
root |
1.4 |
#define DSIZE 2821120 |
| 43 |
root |
1.1 |
|
| 44 |
|
|
unsigned char data[DSIZE], data2[DSIZE*2], data3[DSIZE*2]; |
| 45 |
|
|
|
| 46 |
|
|
int main(void) |
| 47 |
|
|
{ |
| 48 |
|
|
tval s; |
| 49 |
|
|
tval si[1000]; |
| 50 |
|
|
int i, l, j; |
| 51 |
|
|
int min = 1<<30; |
| 52 |
root |
1.2 |
int lp; |
| 53 |
root |
1.7 |
char buf[8192]; |
| 54 |
|
|
int p[2]; |
| 55 |
root |
1.8 |
int evfd = eventfd (0, 0); |
| 56 |
|
|
long ctr = 1; |
| 57 |
root |
1.7 |
|
| 58 |
|
|
pipe (p); |
| 59 |
root |
1.1 |
|
| 60 |
|
|
FILE *f = fopen ("data", "r"); |
| 61 |
|
|
fread (data, DSIZE, 1, f); |
| 62 |
|
|
fclose (f); |
| 63 |
root |
1.7 |
|
| 64 |
root |
1.8 |
signal (SIGURG, sigu); |
| 65 |
|
|
|
| 66 |
root |
1.7 |
for (lp = 0; lp < 100000; lp++) { |
| 67 |
root |
1.6 |
s=stamp(); |
| 68 |
root |
1.7 |
|
| 69 |
root |
1.8 |
snprintf (buf, 64, "<1.%llx>", (unsigned long long)0xa234567812ULL); |
| 70 |
|
|
//kill (0, SIGURG); |
| 71 |
|
|
//write (evfd, &ctr, 8); |
| 72 |
|
|
//read (evfd, &ctr, 8); |
| 73 |
|
|
// write (p[1], &buf, 1); |
| 74 |
|
|
// read (p[0], &buf, 4); |
| 75 |
root |
1.7 |
|
| 76 |
root |
1.6 |
si[0]=measure(s); |
| 77 |
root |
1.7 |
|
| 78 |
|
|
//j = lzf_decompress (data2, l, data3, DSIZE*2); |
| 79 |
root |
1.1 |
|
| 80 |
|
|
printf ("\r%10d (%d) ", si[0], l); |
| 81 |
|
|
if (si[0] < min && si[0] > 0) |
| 82 |
|
|
{ |
| 83 |
|
|
printf ("\n"); |
| 84 |
|
|
min = si[0]; |
| 85 |
|
|
} |
| 86 |
|
|
|
| 87 |
|
|
fflush (stdout); |
| 88 |
|
|
|
| 89 |
root |
1.7 |
//assert (memcmp (data, data3, DSIZE) == 0); |
| 90 |
root |
1.1 |
} |
| 91 |
|
|
return 0; |
| 92 |
|
|
} |
| 93 |
|
|
|
| 94 |
|
|
|
| 95 |
|
|
|