SHD-CacheAttackLab/Part1-Timing/run.py

42 lines
995 B
Python
Raw Permalink Normal View History

2023-01-31 20:19:02 +00:00
import json
import os
import matplotlib.pyplot as plt
import subprocess
import csv
from tqdm import tqdm
# Run your code:
2024-02-07 14:23:56 +00:00
# Make sure that your code is using print_results_for_visualization
executable_filename = ['make', 'run-visual']
2023-01-31 20:19:02 +00:00
num_runs = 100
graph_repo = "data"
os.makedirs(graph_repo, exist_ok=True)
fancy_num_runs = range(0, num_runs, 1)
for run_id in tqdm(fancy_num_runs):
p = subprocess.run(executable_filename,
stdout=subprocess.PIPE, universal_newlines=True)
reader = csv.reader(p.stdout.splitlines())
dict_of_lists = dict()
for store_lev in range(1, 4+1, 1):
dict_of_lists[store_lev] = []
store_level = 1
for row in reader:
temp = row[0].split(' ')[:-1]
dict_of_lists[store_level] = list(map(int, temp))
store_level+=1
#print(dict_of_lists)
filename = graph_repo+"/run"+str(run_id)+".json"
jsonFile = open(filename, "w")
jsonFile.write(json.dumps(dict_of_lists))
jsonFile.close()