-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathplot_data.c
More file actions
53 lines (47 loc) · 1.48 KB
/
plot_data.c
File metadata and controls
53 lines (47 loc) · 1.48 KB
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
#include <dirent.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char* argv[]) {
if (argc < 2) {
printf("Error, please specify the folder containing the benchmark data!\n");
return -1;
}
char* bench_dir = argv[1];
DIR* d;
struct dirent* dir;
d = opendir(bench_dir);
if (!d) {
printf("Error opening folder \"%s\"!\n", bench_dir);
return -1;
}
char* gnu_commands[6];
gnu_commands[0] = "set title \"GEMM Performance\" font \",14\"";
gnu_commands[1] = "set key right bottom";
gnu_commands[2] = "set grid";
gnu_commands[3] = "set ylabel \"GFLOPS\" font \",11\"";
gnu_commands[4] = "set xlabel \"M=N=K\" font \",11\"";
char buffer[10000];
strcpy(buffer, "plot ");
while ((dir = readdir(d)) != NULL) {
if (dir->d_type == DT_REG) {
char* title = strndup(dir->d_name, strchr(dir->d_name, '.') - dir->d_name);
strcat(buffer, "\"");
strcat(buffer, bench_dir);
strcat(buffer, "/");
strcat(buffer, dir->d_name);
strcat(buffer, "\" using 1:2 title \"");
strcat(buffer, title);
strcat(buffer, "\" with lines lw 2, ");
free(title);
}
}
gnu_commands[5] = buffer;
closedir(d);
FILE* gnupipe = NULL;
gnupipe = popen("gnuplot -persistent", "w");
for (int i = 0; i < 6; i++) {
fprintf(gnupipe, "%s\n", gnu_commands[i]);
}
return 0;
}