本文整理汇总了Python中console.Console.timeSinceLast方法的典型用法代码示例。如果您正苦于以下问题:Python Console.timeSinceLast方法的具体用法?Python Console.timeSinceLast怎么用?Python Console.timeSinceLast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类console.Console
的用法示例。
在下文中一共展示了Console.timeSinceLast方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _analyzeFile
# 需要导入模块: from console import Console [as 别名]
# 或者: from console.Console import timeSinceLast [as 别名]
def _analyzeFile(self, filename):
Console.write("Analyzing '{}'".format(filename), Console.Style.Important)
# prepare a packet data source
source = OfflineSource(filename)
# init the PacketProcessor, which will dissect each packet and retrieve
# some information from them.
pproc = PacketProcessor()
pproc.show_packets = Settings.options['debug.show_packets']
# init the TCPManager, which will reconstruct TCP connections from
# previously dissected TCP packets
tcpman = TCPManager()
# this tells the TCPManager which analyzers should create for
# each TCP thread that is opened
tcpman.analyzer_classes = [HTTPAnalyzer]
# init some counters that will be later used for statistics
count = 0
last_count = 0
msg_period = 3.0
start_time = time.time()
# start obtaining and processing network packets
for packet in source:
# dissect this packet, then use this packet
# to reassemble tcp threads
pproc.run(packet)
tcpman.run(packet)
count += 1
# if count > 100000:
# Console.write("Packet limit has been reached")
# break;
# show a message if msg_period has passed so that the user
# does not get bored to death
if Console.timeSinceLast()>msg_period:
speed = (count - last_count)/msg_period
last_count = count
Console.write("Analyzed {} packets at {:.2f} p/sec.".format(count, speed))
# after completion show elapsed time, number of packets and number of threads
stop_time = time.time()
Console.write("Analyzed {} packets in {:.2f} seconds".format(count, stop_time - start_time))
Console.write("Found {} TCP threads".format(tcpman.total_count))