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