当前位置: 首页>>代码示例>>Python>>正文


Python Console.timeSinceLast方法代码示例

本文整理汇总了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))
开发者ID:leandrinux,项目名称:fireherd,代码行数:52,代码来源:app.py


注:本文中的console.Console.timeSinceLast方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。