Skip to content

Instantly share code, notes, and snippets.

@chathurawidanage
Created July 11, 2022 15:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chathurawidanage/323d9efda09581a713cff513a802b220 to your computer and use it in GitHub Desktop.
Save chathurawidanage/323d9efda09581a713cff513a802b220 to your computer and use it in GitHub Desktop.
from cProfile import label
import re
from datetime import datetime
host_mem = 73
dev_mem = 16
def plot(worker = '0'):
print("Plotting worker", worker)
logs = open("theseus_log/batch_log."+worker+".log")
lines = logs.readlines()
print(len(lines), "lines")
p = re.compile('(\d\d\d\d-\d\d-\d\d\s\d\d:\d\d:\d\d.\d\d\d).+\susage\s:\s([0-9]+)')
p_dev = re.compile('(\d\d\d\d-\d\d-\d\d\s\d\d:\d\d:\d\d.\d\d\d).+\susage\sDev\s:\s([0-9]+)')
mem = []
mem_x = []
mem_dev = []
mem_dev_x = []
for line in lines:
m = p.match(line)
m_dev = p_dev.match(line)
if m:
mem_x.append(datetime.fromisoformat(m.group(1)))
mem.append(m.group(2))
elif m_dev:
mem_dev_x.append(datetime.fromisoformat(m_dev.group(1)))
mem_dev.append(m_dev.group(2))
import matplotlib.pyplot as plt
print("Drawing...")
plt.plot(mem_x, mem, label="host")
plt.plot(mem_dev_x, mem_dev, label="device")
plt.title('Q18 - HOST = '+str(host_mem)+'GB, DEVICE = '+str(dev_mem)+'GB | Worker '+str(worker))
plt.xlabel('Memory Event')
plt.ylabel('Memory (GB)')
plt.legend()
plt.savefig('img/q18_'+str(host_mem)+'g_'+str(dev_mem)+'g_'+worker+'.png')
plt.close()
for i in range(0,8):
plot(str(i))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment