import re
f1=file('youare.txt','r')#你的文件
data1=f1.readlines()
# print data1
f1.close()
results = []
var = []
value = []
num = []
p = 0
s = 0
for line in data1:
data2=line.split()
if "Time" == data2[0]:
continue
m = re.findall("CacheHits", data2[2])
if m and (float(data2[3])>10):
for i in range(0, len(var)):
if data2[1] == var[i]:
value[i] = str(int(data2[3])+int(value[i]))
p = 1
break
if p == 0:
var.append(data2[1])
value.append(data2[3])
m = re.findall("CacheMisses", data2[2])
if m:
for i in range(0, len(var)):
if data2[1] == var[i]:
if len(num) == len(var):
num[i] = str(int(data2[3])+int(num[i]))
else:
num.append(data2[3])
for i in range(0, len(var)):
results.append(var[i] + "\t\t" + str(float(value[i])/(float(value[i]) + float(num[i]))) + "\n")
f2=file('your.txt','w')#目标生成文件
f2.writelines(results)
f2.close()
ndnsim 仿真算命中率Python
最新推荐文章于 2021-04-04 21:56:54 发布