aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fl.fischer@fau.de>2018-08-24 22:15:32 +0200
committerFlorian Fischer <florian.fl.fischer@fau.de>2018-08-24 22:15:32 +0200
commit933592db4782b0fe155231f805e017330efd5f65 (patch)
tree95f0a128a5c846db7a4c9b8a354133776d78f6b0
parent423cc4f28dc7fbf86ee951a22b7c69cfe3d0131c (diff)
downloadallocbench-933592db4782b0fe155231f805e017330efd5f65.tar.gz
allocbench-933592db4782b0fe155231f805e017330efd5f65.zip
use new memusage gathering in loop
-rw-r--r--benchmarks/bench_loop.c38
-rw-r--r--loop.py11
-rw-r--r--print_status_on_exit.c9
3 files changed, 18 insertions, 40 deletions
diff --git a/benchmarks/bench_loop.c b/benchmarks/bench_loop.c
index ecfa5d6..af7ff10 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 < 7) {
- fprintf(stderr, "Usage: %s <benchmark> <num threads> <num allocations> <max size> <num of stored allocations> <print mem stats> [<output-file>]\n", argv[0]);
+ if (argc < 6) {
+ fprintf(stderr, "Usage: %s <benchmark> <num threads> <num allocations> <max size> <num of stored allocations>\n", argv[0]);
return 1;
}
@@ -104,34 +104,14 @@ int main(int argc, char* argv[]) {
}
}
- if (strcmp(argv[6], "yes") == 0)
+ if (argc == 7)
{
- 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);
+ 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);
}
return 0;
diff --git a/loop.py b/loop.py
index d13183c..2709e68 100644
--- a/loop.py
+++ b/loop.py
@@ -64,13 +64,16 @@ class Benchmark_Loop( Benchmark ):
# Collect memory consumtion on first run
if run == 1:
- subprocess.run((cur_cmd + " yes loop.out").split(), env=os.environ)
- with open("loop.out", "r") as f:
+ os.environ["LD_PRELOAD"] = "build/print_status_on_exit.so " + os.environ["LD_PRELOAD"]
+ subprocess.run(cur_cmd.split(), env=os.environ)
+ with open("status", "r") as f:
for l in f.readlines():
if l.startswith("VmHWM:"):
result["rssmax"] = l.split()[1]
- target_cmd = perf_cmd + cur_cmd + " no"
+ os.environ["LD_PRELOAD"] = t["LD_PRELOAD"]
+
+ target_cmd = perf_cmd + cur_cmd
if verbose:
print("\n" + tname, t, "\n", target_cmd, "\n")
@@ -84,7 +87,7 @@ class Benchmark_Loop( Benchmark ):
output = p.stderr
if p.returncode != 0:
- print("\n" + " ".join(target_cmd), "exited with", p.returncode, ".\n Aborting Benchmark.")
+ print("\n" + target_cmd, "exited with", p.returncode, ".\n Aborting Benchmark.")
print(tname, t)
print(output)
print(p.stdout)
diff --git a/print_status_on_exit.c b/print_status_on_exit.c
index 686817e..e2363c9 100644
--- a/print_status_on_exit.c
+++ b/print_status_on_exit.c
@@ -64,8 +64,6 @@ void *malloc(size_t size)
initializing = 1;
init();
initializing = 0;
-
- fprintf(stdout, "jcheck: allocated %lu bytes of temp memory in %lu chunks during initialization\n", tmppos, tmpallocs);
}
else
{
@@ -78,12 +76,11 @@ void *malloc(size_t size)
}
else
{
- fprintf(stdout, "jcheck: too much memory requested during initialisation - increase tmpbuff size\n");
+ fprintf(stderr, "jcheck: too much memory requested during initialisation - increase tmpbuff size\n");
exit(1);
}
}
}
-
return myfn_malloc(size);
}
@@ -92,9 +89,7 @@ void free(void *ptr)
// something wrong if we call free before one of the allocators!
if (myfn_malloc == NULL)
init();
- if (ptr >= (void*) tmpbuff && ptr <= (void*)(tmpbuff + tmppos))
- fprintf(stdout, "freeing temp memory\n");
- else
+ if (!(ptr >= (void*) tmpbuff && ptr <= (void*)(tmpbuff + tmppos)))
myfn_free(ptr);
}