aboutsummaryrefslogtreecommitdiff
path: root/benchmarks/bench_loop.c
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fl.fischer@fau.de>2018-08-20 14:14:03 +0200
committerFlorian Fischer <florian.fl.fischer@fau.de>2018-08-20 14:14:03 +0200
commitb73a146f2d0861926349fa3972dd437ac0bca576 (patch)
treeb433a7ebd1d3c0ec8bbfaf793deb0be7ccbd2067 /benchmarks/bench_loop.c
parent01cdcd79da31f8f390e29eabd062bcbf57ff838d (diff)
downloadallocbench-b73a146f2d0861926349fa3972dd437ac0bca576.tar.gz
allocbench-b73a146f2d0861926349fa3972dd437ac0bca576.zip
add memusage to loop benchmark
Diffstat (limited to 'benchmarks/bench_loop.c')
-rw-r--r--benchmarks/bench_loop.c38
1 files changed, 29 insertions, 9 deletions
diff --git a/benchmarks/bench_loop.c b/benchmarks/bench_loop.c
index af7ff10..ecfa5d6 100644
--- a/benchmarks/bench_loop.c
+++ b/benchmarks/bench_loop.c
@@ -77,8 +77,8 @@ int main(int argc, char* argv[]) {
int num_threads;
struct ThreadArgs thread_args;
- if (argc < 6) {
- fprintf(stderr, "Usage: %s <benchmark> <num threads> <num allocations> <max size> <num of stored allocations>\n", argv[0]);
+ if (argc < 7) {
+ fprintf(stderr, "Usage: %s <benchmark> <num threads> <num allocations> <max size> <num of stored allocations> <print mem stats> [<output-file>]\n", argv[0]);
return 1;
}
@@ -104,14 +104,34 @@ int main(int argc, char* argv[]) {
}
}
- if (argc == 7)
+ if (strcmp(argv[6], "yes") == 0)
{
- FILE* f = stdout;
- if (strcmp(argv[6],"stdout") != 0)
- f = fopen(argv[6], "w");
- malloc_info(0, f);
- if (strcmp(argv[6],"stdout") != 0)
- fclose(f);
+ char buf[4096];
+
+ FILE* status = fopen("/proc/self/status", "r");
+ if (status == NULL)
+ {
+ perror("fopen status");
+ exit(1);
+ }
+
+ FILE* output = stdout;
+ if (argc == 8)
+ {
+ output = fopen(argv[7], "w");
+ if (output == NULL)
+ {
+ perror("fopen output file");
+ exit(1);
+ }
+ }
+
+ while (!feof(status))
+ {
+ fgets(&buf, 4096, status);
+ fprintf(output, "%s", buf);
+ }
+ fclose(status);
}
return 0;