I wrote a direct-mapping cache simulator that takes the following parameters: cache size, line size, memory write cycles, memory read cycles, cache read cycles, cache write cycles.
Now I want to run this program multiple times and plot the output on graphs. This is to help me find or simulate the best parameters for a real cache.
I heard that matplotlib is a great tool to plot graphs. So I wrote this script to run my c++ executable, but How do I plot the output?
import os
import sys
import matplotlib as plt
argc = len(sys.argv)
argv = sys.argv
cmd = './Desktop/assignment6/cache_sim/bin/cache_sim ' + 'wb ' + './Desktop/assignment6/cache_sim/ls.out ' + '1024 ' + '2048 ' + '2 ' +'4 ' + '8 ' + '16 '
os.system(cmd)
I am not familiar with python, so I don't know how to parse the output and then plot it using numpy and matplotlib. if you can sugegst a way I can also change my parameters in a loop and pass run the executable again it would be great.
the output of my code looks like this:
Total misses: 756
Total hits: 170245
Total Memory Read Access Attempts: 127892
Total Memory write Access Attempts: 42353
Total Memory Access Attempts: 170245
Total Memory read Access : 756
Total Memory write Access : 42353
Total # of cycles for cache reads: 255784
Total # of cycles for cache writes: 169412
Total # of cycles for cache access: 425196
Total # of cycles for memory reads: 6048
Total # of cycles for memory writes: 677648
Total # of cycles for memory access: 683696