This commit is contained in:
2021-08-05 11:28:20 +08:00
parent 8f41ed021b
commit e2eecd736f
10 changed files with 575 additions and 0 deletions
+61
View File
@@ -0,0 +1,61 @@
import csv
import sys
import numpy as np
import matplotlib.pyplot as plt
def getXY(fileName: str, target: str, faceId: str, quota: str):
x = []
y = []
with open(fileName, "r") as file:
lines = file.readlines()
lastCount = 0;
beta = 0.6
for line in lines[1:]:
item = line.split("\t")
if len(item) < 5:
continue
capTime = float(item[0])
if int(capTime / 0.5) != lastCount:
lastCount = int(capTime / 0.5)
if item[1] == target and item[2] == faceId and item[4] == quota:
x.append(lastCount * 0.5)
if len(y) == 0:
# 第一次添加
y.append(float(item[5]) * 1000)
else:
# 指数加权平均
y.append(beta * y[len(y) - 1] + (1 - beta) * float(item[5]) * 1000)
return x, y
if __name__ == '__main__':
if len(sys.argv) != 3:
print("Usage: python delay.py <filename> <title>")
exit(0)
filename = sys.argv[1]
delayType = "LastDelay"
x1, y1 = getXY(filename, "C1", "0", delayType)
x2, y2 = getXY(filename, "C2", "0", delayType)
x3, y3 = getXY(filename, "C3", "0", delayType)
x4, y4 = getXY(filename, "C4", "0", delayType)
# x1 = [20, 33, 51, 79, 101, 121, 132, 145, 162, 182, 203, 219, 232, 243, 256, 270, 287, 310, 325]
# y1 = [49, 48, 48, 48, 48, 87, 106, 123, 155, 191, 233, 261, 278, 284, 297, 307, 341, 319, 341]
# x2 = [31, 52, 73, 92, 101, 112, 126, 140, 153, 175, 186, 196, 215, 230, 240, 270, 288, 300]
# y2 = [48, 48, 48, 48, 49, 89, 162, 237, 302, 378, 443, 472, 522, 597, 628, 661, 690, 702]
# x3 = [30, 50, 70, 90, 105, 114, 128, 137, 147, 159, 170, 180, 190, 200, 210, 230, 243, 259, 284, 297, 311]
# y3 = [48, 48, 48, 48, 66, 173, 351, 472, 586, 712, 804, 899, 994, 1094, 1198, 1360, 1458, 1578, 1734, 1797, 1892]
# x = np.arange(20, 350)
l1 = plt.plot(x1, y1, 'r', label='C1', linestyle='-.', marker='+')
l2 = plt.plot(x2, y2, 'g', label='C2', linestyle='-.', marker='x')
l3 = plt.plot(x3, y3, 'b', label='C3', linestyle='-.', marker='d')
l4 = plt.plot(x4, y4, 'aqua', label='C4', linestyle='-.', marker='*')
# plt.plot(x1, y1, 'ro-', x2, y2, 'g+-', x3, y3, 'b^-')
plt.title(sys.argv[2])
plt.xlabel('Time(s)')
plt.ylabel('Delay(ms)')
plt.xlim(0)
plt.ylim(0, 200)
plt.legend(loc=0)
plt.savefig(f"{filename}.svg", format="svg")