-
Notifications
You must be signed in to change notification settings - Fork 0
/
profdiff.c
92 lines (70 loc) · 1.94 KB
/
profdiff.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#include <stdio.h>
#include <string.h>
#include "prof.h"
struct profiledata {
char name[128];
struct profblock blocks[PROFNAME_LAST];
};
int main(int argc, char *argv[])
{
unsigned data_count = 0;
struct profiledata data[128];
if (argc < 3) {
fputs("./profdiff START NEXT ...\n", stderr);
return 1;
}
for (int i = 1; i < argc; i++) {
FILE *f = NULL;
f = fopen(argv[i], "r");
if (!f) {
return 1;
}
strncpy(data[i - 1].name, argv[i], sizeof(data[0].name));
/* FIXME Use proper file format for profile data. */
/* FIXME Check return of fread. */
fread(&(data[i - 1].blocks), sizeof(data[0].blocks[0]), PROFNAME_LAST, f);
fclose(f);
}
data_count = argc - 1;
for (unsigned i = 0; i < data_count; i++) {
printf("name: %s\n", data[i].name);
for (unsigned k = 0; k < PROFNAME_LAST; k++) {
struct profblock *pb = &(data[i].blocks[k]);
printf("%3x %8s %12u %12u %9.1f HZ (%0.5f)\n",
k,
profstr[k],
pb->count_last_frame,
pb->count_total,
1 / pb->clock_last_frame,
pb->clock_last_frame);
}
}
for (unsigned i = 0; i < (data_count - 1); i ++) {
unsigned j = i + 1;
printf("diff: %s %s\n", data[i].name, data[j].name);
for (unsigned k = 0; k < PROFNAME_LAST; k++) {
struct profblock *a = &(data[i].blocks[k]);
struct profblock *b = &(data[j].blocks[k]);
unsigned a_count = a->count_total;
unsigned b_count = b->count_total;
float a_clock = a->clock_total;
float b_clock = b->clock_total;
float a_clock_avg = a_clock / a_count;
float b_clock_avg = b_clock / b_count;
float a_avg_rate = 1 / a_clock_avg;
float b_avg_rate = 1 / b_clock_avg;
float diff_avg_rate = b_avg_rate - a_avg_rate;
/* FIXME Pixel statistics are currently unreliable. */
if (k == PROFNAME_PIXEL)
continue;
printf("%s %12u %12u %9.1f %9.1f %9.1f\n",
profstr[k],
a_count,
b_count,
a_avg_rate,
b_avg_rate,
diff_avg_rate);
}
}
return 0;
}