7
"set title \"PGM Latency Heat Map\"\n"
11
"# Colour runs from white to green\n"
12
"set palette rgbformula -6,2,-3\n"
13
"set cbrange [0:25]\n"
14
"set cblabel \"Density\"\n"
17
"set xrange [-0.5:%u.5]\n"
18
"set yrange [-0.5:%u.5]\n"
21
"plot '-' using 1:2:3 with image\n";
25
const unsigned yrange_max = 2*1000;
26
const unsigned yrange_ivl = 10;
35
const uint32_t i = *((uint32_t*)p1);
36
const uint32_t j = *((uint32_t*)p2);
46
const char src[] = "/tmp/heat.dmp";
48
uint32_t slice_count, alloc_count = 0;
50
unsigned slice = 0, xrange_max = 0, density_max = 0;
52
if (NULL == (fh = fopen (src, "r"))) {
57
/* find time period of dump */
59
if (1 != fread (&slice_count, sizeof (slice_count), 1, fh)) {
62
slice_count = ntohl (slice_count);
63
if (0 == alloc_count) {
64
alloc_count = slice_count;
65
words = malloc (alloc_count * sizeof (uint32_t) * 2);
66
} else if (slice_count > alloc_count) {
67
alloc_count = slice_count;
68
words = realloc (words, alloc_count * sizeof (uint32_t) * 2);
70
if (slice_count != fread (words, sizeof (uint32_t) * 2, slice_count, fh)) {
74
for (int_fast32_t i = slice_count - 1; i >= 0; i--) {
75
const unsigned density = ntohl (words[(2*i)+1]);
76
if (density > density_max)
77
density_max = density;
83
printf (header, xrange_max - 1, yrange_max - yrange_ivl);
86
if (1 != fread (&slice_count, sizeof (slice_count), 1, fh)) {
89
slice_count = ntohl (slice_count);
90
if (slice_count != fread (words, sizeof (uint32_t) * 2, slice_count, fh)) {
94
for (int_fast32_t i = slice_count - 1; i >= 0; i--) {
95
words[(2*i)+0] = ntohl (words[(2*i)+0]);
96
words[(2*i)+1] = ((ntohl (words[(2*i)+1]) * 25) + (density_max - 1)) / density_max;
98
qsort ((void*)words, slice_count, sizeof (uint32_t) * 2, key_compare);
99
for (int_fast32_t i = 0, j = 0; i < slice_count; i++) {
100
while ((j * yrange_ivl) < words[(2*i)+0]) {
101
if ((j * yrange_ivl) >= yrange_max)
105
(unsigned)(j * yrange_ivl));
108
if ((j * yrange_ivl) >= yrange_max)
110
printf ("%u %u %u\n",
112
(unsigned)(j * yrange_ivl),
113
(unsigned)words[(2*i)+1]);
116
for (int_fast32_t j = words[(2*(slice_count-1))+0] + yrange_ivl; j < yrange_max; j += yrange_ivl) {