def compare_checksum(cnt): s = 'A' * 80 start = time.time() for i in range(cnt): dpkt.in_cksum(s) print('dpkt.in_cksum:', cnt / (time.time() - start), 'pps') start = time.time() for i in range(cnt): dnet.ip_cksum_carry(dnet.ip_cksum_add(s, 0)) print('dnet.ip_cksum_add/carry:', cnt / (time.time() - start), 'pps')
def in_cksum_add(s, buf): return dnet.ip_cksum_add(buf, s)