+histogram
This commit is contained in:
parent
1ec01d6c37
commit
7b4fc6f3ab
@ -10,48 +10,49 @@ import json
|
||||
import getopt
|
||||
import math
|
||||
import concurrent.futures as CF
|
||||
import libpar as par
|
||||
|
||||
num_bins = 1000
|
||||
num_bins = 100
|
||||
extra_pct = []
|
||||
|
||||
def saveplot(files, data):
|
||||
def saveplot(fp : str, data : [], title : str):
|
||||
plt.hist(data, num_bins)
|
||||
plt.xlabel("Latency")
|
||||
plt.xlabel("Delay")
|
||||
plt.title(title)
|
||||
plt.ylabel("Frequency")
|
||||
plt.title(os.path.basename(files))
|
||||
plt.title(os.path.basename(fp))
|
||||
f = plt.gcf()
|
||||
f.set_size_inches(11.69, 8.27)
|
||||
f.savefig(files + ".png", dpi=160)
|
||||
f.savefig(fp + "_" + title + "_" + ".png", dpi=160)
|
||||
plt.clf()
|
||||
print("Generated - " + files + ".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
|
||||
|
||||
print("Generated - " + fp + "_" + title + "_" + ".png")
|
||||
|
||||
executor = CF.ProcessPoolExecutor(max_workers=int(os.cpu_count()))
|
||||
|
||||
def process_file(each_dir):
|
||||
try:
|
||||
print("Processing " + each_dir + " ...")
|
||||
data = memparse.parse_mut_sample(each_dir)[1]
|
||||
output_extra_percentile(data)
|
||||
sdata = sanitize(data)
|
||||
saveplot(each_dir, sdata)
|
||||
except:
|
||||
None
|
||||
with open(each_dir, 'r') as f:
|
||||
parser = par.khat_parser()
|
||||
parser.parse(f.read())
|
||||
|
||||
sh = []
|
||||
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):
|
||||
for subdir in os.listdir(rootdir):
|
||||
|
Loading…
Reference in New Issue
Block a user