-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmetrics.c
65 lines (51 loc) · 1.44 KB
/
metrics.c
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
#include <stdio.h>
static FILE *metrics = NULL;
void metrics_prepare(const char *fname, int connect_timeout)
{
metrics = fopen(fname, "w");
fwrite(&connect_timeout, 4, 1, metrics);
}
void mev_packet(unsigned long long time, int fd)
{
fwrite("\xe0", 1, 1, metrics);
fwrite(&time, 8, 1, metrics);
fwrite(&fd, 4, 1, metrics);
}
void mev_epoll(unsigned long long time, int returned, int timeout)
{
fwrite("\xe1", 1, 1, metrics);
fwrite(&time, 8, 1, metrics);
fwrite(&returned, 4, 1, metrics);
fwrite(&timeout, 4, 1, metrics);
}
void mev_ret(unsigned long long time, unsigned long long start, char kind)
{
int delta = time-start;
fwrite("\xe2", 1, 1, metrics);
fwrite(&time, 8, 1, metrics);
fwrite(&delta, 4, 1, metrics);
fwrite(&kind, 1, 1, metrics);
}
void mev_delta(unsigned long long time, unsigned long long start)
{
int delta = time-start;
fwrite("\xe3", 1, 1, metrics);
fwrite(&time, 8, 1, metrics);
fwrite(&delta, 4, 1, metrics);
}
void mev_sendinfo(unsigned long long time, unsigned long long start, int send_count)
{
int delta = time-start;
fwrite("\xe4", 1, 1, metrics);
fwrite(&time, 8, 1, metrics);
fwrite(&delta, 4, 1, metrics);
fwrite(&send_count, 4, 1, metrics);
}
void mev_delinfo(unsigned long long time, unsigned long long start, int del_count)
{
int delta = time-start;
fwrite("\xe5", 1, 1, metrics);
fwrite(&time, 8, 1, metrics);
fwrite(&delta, 4, 1, metrics);
fwrite(&del_count, 4, 1, metrics);
}