-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathioprofile.py
More file actions
76 lines (64 loc) · 2.84 KB
/
ioprofile.py
File metadata and controls
76 lines (64 loc) · 2.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
"import requeired packages and class"
import urllib.request as urllib2
import matplotlib.pyplot as plt
from bs4 import BeautifulSoup
import pandas as pd
import xlsxwriter
from openpyxl.reader.excel import load_workbook
from openpyxl.utils.dataframe import dataframe_to_rows
import openpyxl
"This class to extract ADDM and Foreground wait event data and visualize it and store it in excel"
class IOProfile:
def __init__ (self):
"Constructor"
def drawTosheet(sheetName,pos, png):
book = load_workbook('output.xlsx')
newSheet=book.create_sheet(sheetName)
for r in dataframe_to_rows(IOProfile.ioDF, index=False,header=True):
newSheet.append(r)
for fig in png:
newSheet.add_image( openpyxl.drawing.image.Image(fig),pos)
pos="J10"
book.save("output.xlsx")
def ioprofile(self,soup):
print ("\nExtracting IO Profile details\n")
cols = []
rows=[]
ioTable = soup.find('table', summary='This table displays IO profile')
for row in ioTable.find_all("tr"):
cells = row.find_all('th')
for val in cells:
cols.append (val.find(text = True))
for row in ioTable.find_all("tr"):
cells = row.find_all('td')
for val in cells:
rows.append (val.find(text=True))
x = [0, 4, 8, 12, 16,20,24,28,32,36,40]
y = [4, 8, 12, 16,20,24,28,32,36,40,44]
IOProfile.ioDF = pd.DataFrame(cols)
count=1
for i, j in zip(x, y):
IOProfile.ioDF[count] = rows[i:j]
count = count+1
IOProfile.ioDF = IOProfile.ioDF.transpose()
IOProfile.ioDF.columns=cols
IOProfile.ioDF = IOProfile.ioDF.iloc[1:]
IOProfile.ioDF.columns = IOProfile.ioDF.columns.fillna('Types')
IOProfile.ioDF.rename (columns = lambda x: x.strip().replace(' ','_').lower(),inplace= True)
for col in IOProfile.ioDF.columns:
IOProfile.ioDF[col] = IOProfile.ioDF[col].apply (lambda x: x.replace(',',''))
for col in IOProfile.ioDF.columns:
if col != 'types':
IOProfile.ioDF[col] = IOProfile.ioDF[col].astype('float')
IOProfile.ioDF = IOProfile.ioDF.iloc[:8]
plt.figure(figsize=(8, 5))
plt.plot(IOProfile.ioDF['types'],IOProfile.ioDF['read+write_per_second'])
plt.plot(IOProfile.ioDF['types'],IOProfile.ioDF['read_per_second'])
plt.plot(IOProfile.ioDF['types'],IOProfile.ioDF['write_per_second'])
plt.legend(['read+write_per_second','read_per_second','write_per_second'], prop={'size': 6})
plt.title('IO Profile', size=15)
plt.ylabel('# of IO Per Second', size=8)
plt.xticks(rotation=5,size=5)
plt.yticks(size=5)
plt.savefig('ioprofile.png')
IOProfile.drawTosheet('IO Profile','H2',["ioprofile.png"])