|
| 1 | +#!/bin/python |
| 2 | + |
| 3 | +import subprocess |
| 4 | +import os |
| 5 | +import re |
| 6 | +import matplotlib.pyplot as plt |
| 7 | + |
| 8 | +STATIC=0 |
| 9 | +HOTNESS=1 |
| 10 | + |
| 11 | +re_exec_adjusted=re.compile('Measured execution time \[millis_thread\|millis_thread_adjusted\|millis_system\]: \[[0-9]*\|([0-9]*)\|[0-9]*\]') |
| 12 | +re_accesses_per_malloc=re.compile('Stats \[accesses_per_malloc\|average_size\]: \[([0-9\.]*)\|[0-9\.]*\]') |
| 13 | + |
| 14 | +def get_adjusted_execution_time(iterations, static_hotness): |
| 15 | + ''' |
| 16 | + Returns: |
| 17 | + (adjusted_time, accesses_per_allocation, average_size) |
| 18 | + ''' |
| 19 | + m_env = os.environ.copy() |
| 20 | + m_env['MEMKIND_DEBUG']='1' |
| 21 | + m_env['LD_LIBRARY_PATH']='.libs' |
| 22 | + args=[] |
| 23 | + if static_hotness == STATIC: |
| 24 | + args.append('static') |
| 25 | + elif static_hotness == HOTNESS: |
| 26 | + args.append('hotness') |
| 27 | + else: |
| 28 | + raise Exception('Incorrect function argument!') |
| 29 | + args.append(str(iterations)) |
| 30 | + ret = subprocess.run(['./utils/memtier_zipf_bench/.libs/memtier_zipf_bench'] + args, env=m_env, stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
| 31 | + # what do we have: |
| 32 | + # 1. Ratio history |
| 33 | + # 2. Results |
| 34 | + stats = ret.stdout.decode() |
| 35 | + adjusted_exec_time_millis = int(re_exec_adjusted.findall(stats)[0]) |
| 36 | + accesses_per_malloc = float(re_accesses_per_malloc.findall(stats)[0]) |
| 37 | + return adjusted_exec_time_millis, accesses_per_malloc |
| 38 | + |
| 39 | +iterations = [20, 40, 80, 160, 320] |
| 40 | + |
| 41 | +execution_times_static = [] |
| 42 | +execution_times_hotness = [] |
| 43 | +accesses_per_malloc_static = [] |
| 44 | +accesses_per_malloc_hotness = [] |
| 45 | + |
| 46 | +for it in iterations: |
| 47 | + static_time, static_acc = get_adjusted_execution_time(it, STATIC) |
| 48 | + hotness_time, hotness_acc = get_adjusted_execution_time(it, HOTNESS) |
| 49 | + execution_times_static.append(static_time) |
| 50 | + execution_times_hotness.append(hotness_time) |
| 51 | + accesses_per_malloc_static.append(static_acc) |
| 52 | + accesses_per_malloc_hotness.append(hotness_acc) |
| 53 | + |
| 54 | +plt.plot(accesses_per_malloc_static, execution_times_static, label='static') |
| 55 | +plt.plot(accesses_per_malloc_hotness, execution_times_hotness, label='hotness') |
| 56 | +plt.grid() |
| 57 | +plt.show() |
| 58 | + |
| 59 | +plt.plot(accesses_per_malloc_static, execution_times_static, label='static') |
| 60 | +plt.plot(accesses_per_malloc_hotness, execution_times_hotness, label='hotness') |
| 61 | +plt.grid() |
| 62 | +plt.savefig('stats.png') |
| 63 | + |
| 64 | + |
0 commit comments