-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvm_perf.c
More file actions
82 lines (66 loc) · 1.77 KB
/
vm_perf.c
File metadata and controls
82 lines (66 loc) · 1.77 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
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
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include "vm_perf.h"
/*
struct vm_perf_options{
int time_limit; // Maximum time to run tests
int verbose; // Output
};
static int parse_options(struct vm_perf_options *options, const int argc, char * const argv[]){
int opt;
while((opt = getopt(argc, argv, "hvt:")) != -1){
switch(opt){
case 'v': options->verbose = 1; break;
case 't': options->time_limit = atoi(optarg); break;
case 'h':
printf("%s-%s\n", argv[0], VERSION);
printf("Options:\n");
printf("-v \t Enable verbose output\n");
printf("-t 20 \t Time limit for testing in seconds\n");
printf("-h help");
break;
default:
fprintf(stderr, "Unknown option '%c'\n", opt);
return 1;
}
}
return 0;
};*/
void vm_perf_report(const struct vm_perf_result *bm){
printf("{\"vm_perf\":\"%s\",", VERSION);
printf("\"modules\":{");
//printf("Memory:%s\n", bm->mem_info);
//printf("Disk:%s\n", bm->disk_info);
sys_report(&bm->sys); putchar(',');
cpu_report(&bm->cpu); putchar(',');
net_report(&bm->net); putchar(',');
mem_report(&bm->mem); putchar(',');
disk_report(&bm->disk);
printf("}}");
fflush(stdout);
}
int main(const int argc, char * const argv[]){
struct vm_perf_result benchmark;
if(geteuid() != 0){
fprintf(stderr, "Error: test must be run as root\n");
return 1;
}
//if(parse_options(&options, argc, argv) == 1)
// return 1;
sys_info(&benchmark.sys);
cpu_bench(&benchmark.cpu);
net_bench(&benchmark.net);
mem_bench(&benchmark.mem);
disk_bench(&benchmark.disk);
vm_perf_report(&benchmark);
int i;
for(i=0; i < NUM_INFO_PATHS; ++i)
free(benchmark.sys.info[i]);
free(benchmark.disk.disk_stats);
return 0;
}