+histogram
This commit is contained in:
parent
1ec01d6c37
commit
7b4fc6f3ab
@ -10,48 +10,49 @@ import json
|
|||||||
import getopt
|
import getopt
|
||||||
import math
|
import math
|
||||||
import concurrent.futures as CF
|
import concurrent.futures as CF
|
||||||
|
import libpar as par
|
||||||
|
|
||||||
num_bins = 1000
|
num_bins = 100
|
||||||
extra_pct = []
|
extra_pct = []
|
||||||
|
|
||||||
def saveplot(files, data):
|
def saveplot(fp : str, data : [], title : str):
|
||||||
plt.hist(data, num_bins)
|
plt.hist(data, num_bins)
|
||||||
plt.xlabel("Latency")
|
plt.xlabel("Delay")
|
||||||
|
plt.title(title)
|
||||||
plt.ylabel("Frequency")
|
plt.ylabel("Frequency")
|
||||||
plt.title(os.path.basename(files))
|
plt.title(os.path.basename(fp))
|
||||||
f = plt.gcf()
|
f = plt.gcf()
|
||||||
f.set_size_inches(11.69, 8.27)
|
f.set_size_inches(11.69, 8.27)
|
||||||
f.savefig(files + ".png", dpi=160)
|
f.savefig(fp + "_" + title + "_" + ".png", dpi=160)
|
||||||
plt.clf()
|
plt.clf()
|
||||||
print("Generated - " + files + ".png")
|
print("Generated - " + fp + "_" + title + "_" + ".png")
|
||||||
|
|
||||||
def output_extra_percentile(data):
|
|
||||||
a = np.array(data)
|
|
||||||
for pct in extra_pct:
|
|
||||||
p = np.percentile(a, pct)
|
|
||||||
print(str(pct) + "th: " + str(p))
|
|
||||||
|
|
||||||
def sanitize(data):
|
|
||||||
ret = []
|
|
||||||
a = np.array(data)
|
|
||||||
p99 = np.percentile(a, 99)
|
|
||||||
for i in data:
|
|
||||||
if i <= p99:
|
|
||||||
ret.append(i)
|
|
||||||
return ret
|
|
||||||
|
|
||||||
|
|
||||||
executor = CF.ProcessPoolExecutor(max_workers=int(os.cpu_count()))
|
executor = CF.ProcessPoolExecutor(max_workers=int(os.cpu_count()))
|
||||||
|
|
||||||
def process_file(each_dir):
|
def process_file(each_dir):
|
||||||
try:
|
try:
|
||||||
print("Processing " + each_dir + " ...")
|
print("Processing " + each_dir + " ...")
|
||||||
data = memparse.parse_mut_sample(each_dir)[1]
|
with open(each_dir, 'r') as f:
|
||||||
output_extra_percentile(data)
|
parser = par.khat_parser()
|
||||||
sdata = sanitize(data)
|
parser.parse(f.read())
|
||||||
saveplot(each_dir, sdata)
|
|
||||||
except:
|
sh = []
|
||||||
None
|
ss = []
|
||||||
|
ch = []
|
||||||
|
cs = []
|
||||||
|
for pt in parser.datapt:
|
||||||
|
sh.append(pt.s_htx - pt.s_hrx)
|
||||||
|
ss.append(pt.s_stx - pt.s_srx)
|
||||||
|
ch.append(pt.c_hrx - pt.c_htx)
|
||||||
|
cs.append(pt.c_srx - pt.c_stx)
|
||||||
|
|
||||||
|
saveplot(each_dir, sh, "server_hw_delay")
|
||||||
|
saveplot(each_dir, ss, "server_sw_delay")
|
||||||
|
saveplot(each_dir, ch, "client_hw_delay")
|
||||||
|
saveplot(each_dir, cs, "client_sw_delay")
|
||||||
|
|
||||||
|
except Exception:
|
||||||
|
print("Unexpected error:", sys.exc_info())
|
||||||
|
|
||||||
def process_dir(rootdir):
|
def process_dir(rootdir):
|
||||||
for subdir in os.listdir(rootdir):
|
for subdir in os.listdir(rootdir):
|
||||||
|
Loading…
Reference in New Issue
Block a user