chknet.py
来自「基于4个mips核的noc设计」· Python 代码 · 共 43 行
PY
43 行
import os, sys, string, ref = open(sys.argv[1])packet = []times = []while 1 : l = f.readline() if l == '' : break s = string.split(l) if s[2] == 'sending' : ax, ay = int(s[3][6:7]),int(s[3][8:9]) d = s[4][5:] t= int(s[5]) packet.append( (ax,ay,d,t) ) elif s[1] == 'received' : ax, ay = int(s[0][3:4]),int(s[0][4:5]) d = s[2] t = int(s[3]) pn = 0 while pn < len(packet): p = packet[pn] if p[2]==d and p[0]==ax and p[1]==ay : times.append( t - p[3] ) break pn = pn+1 if pn == len(packet) : print 'unexpected receive',ax,ay,d,t else: del packet[pn]for p in packet: print 'lost sent (%d,%d) %s @ %d'%p times.sort()sum = reduce(lambda x, y: long(x)+long(y), times)print '%d packets'%(len(times))print 'min=%d, max=%d, avg=%d'%(times[0], times[-1], int(sum/len(times)))
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?