-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlotBrowsertime.py
97 lines (80 loc) · 3.99 KB
/
PlotBrowsertime.py
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import argparse
import pandas as pd
import re
import seaborn as sns
from matplotlib import pyplot as plt
def convert_string_to_milliseconds(string):
if string[-3:len(string)] == "ms," or string[-2:len(string)] == "ms":
return int(string[0:len(string)-3])
elif string[-2:len(string)] == "s," or string[-1:len(string)] == "s":
return int(float(string[0:len(string)-2]) * 1000)
else:
return 0
parser = argparse.ArgumentParser(prog='Get')
parser.add_argument('ter')
parser.add_argument('sat')
parser.add_argument('bond')
args = parser.parse_args()
ter_df = pd.DataFrame(columns=['website', 'requests', 'TTFB', 'firstPaint', 'FCP', 'DOMContentLoaded', 'LCP', 'CLS', 'TBT', 'CPUBenchmark', 'Load'])
sat_df = pd.DataFrame(columns=['website', 'requests', 'TTFB', 'firstPaint', 'FCP', 'DOMContentLoaded', 'LCP', 'CLS', 'TBT', 'CPUBenchmark', 'Load'])
bond_df = pd.DataFrame(columns=['website', 'requests', 'TTFB', 'firstPaint', 'FCP', 'DOMContentLoaded', 'LCP', 'CLS', 'TBT', 'CPUBenchmark', 'Load'])
with open(args.ter, 'r') as r:
for line in r:
parts = line.split()
entry = dict()
entry["website"] = parts[3]
entry["requests"] = int(parts[4])
entry["TTFB"] = convert_string_to_milliseconds(parts[7])
entry["firstPaint"] = convert_string_to_milliseconds(parts[9])
entry["FCP"] = convert_string_to_milliseconds(parts[11])
entry["DOMContentLoaded"] = convert_string_to_milliseconds(parts[13])
entry["LCP"] = convert_string_to_milliseconds(parts[15])
entry["CLS"] = float(parts[17][0:len(parts[17])-1])
entry["TBT"] = convert_string_to_milliseconds(parts[19])
entry["CPUBenchmark"] = convert_string_to_milliseconds(parts[21])
entry["Load"] = convert_string_to_milliseconds(parts[23])
ter_df = pd.concat([ter_df, pd.DataFrame.from_records([entry])], ignore_index=True)
with open(args.sat, 'r') as r:
for line in r:
parts = line.split()
entry = dict()
entry["website"] = parts[3]
entry["requests"] = int(parts[4])
entry["TTFB"] = convert_string_to_milliseconds(parts[7])
entry["firstPaint"] = convert_string_to_milliseconds(parts[9])
entry["FCP"] = convert_string_to_milliseconds(parts[11])
entry["DOMContentLoaded"] = convert_string_to_milliseconds(parts[13])
entry["LCP"] = convert_string_to_milliseconds(parts[15])
entry["CLS"] = float(parts[17][0:len(parts[17])-1])
entry["TBT"] = convert_string_to_milliseconds(parts[19])
entry["CPUBenchmark"] = convert_string_to_milliseconds(parts[21])
entry["Load"] = convert_string_to_milliseconds(parts[23])
sat_df = pd.concat([sat_df, pd.DataFrame.from_records([entry])], ignore_index=True)
with open(args.bond, 'r') as r:
for line in r:
parts = line.split()
entry = dict()
entry["website"] = parts[3]
entry["requests"] = int(parts[4])
entry["TTFB"] = convert_string_to_milliseconds(parts[7])
entry["firstPaint"] = convert_string_to_milliseconds(parts[9])
entry["FCP"] = convert_string_to_milliseconds(parts[11])
entry["DOMContentLoaded"] = convert_string_to_milliseconds(parts[13])
entry["LCP"] = convert_string_to_milliseconds(parts[15])
entry["CLS"] = float(parts[17][0:len(parts[17])-1])
entry["TBT"] = convert_string_to_milliseconds(parts[19])
entry["CPUBenchmark"] = convert_string_to_milliseconds(parts[21])
entry["Load"] = convert_string_to_milliseconds(parts[23])
bond_df = pd.concat([bond_df, pd.DataFrame.from_records([entry])], ignore_index=True)
ter_df['ds'] = 'ter'
sat_df['ds'] = 'sat'
bond_df['ds'] = 'bond'
df = pd.concat([ter_df, sat_df, bond_df])
colors = ["#55a868", "#4c72b0", "#c44e52"]
customPalette = sns.set_palette(sns.color_palette(colors))
plt.figure(figsize=(10,5))
sns.barplot(x='website', y='Load', hue='ds', data=df, palette=customPalette)
plt.ylabel("Load in ms")
plt.xlabel("")
plt.legend(loc='upper left')
plt.show()