python HammerDB自动驾驶仪日志解析器

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python HammerDB自动驾驶仪日志解析器相关的知识,希望对你有一定的参考价值。

#!/usr/bin/env python

import re

###
# This program is good for parsing the direct output from the Autopilot window.
###

# Settings
infile = 'in.log'
outfile = 'out.data.txt'
# /Settings

r1 = re.compile(r'(\d+) Virtual Users configured')
r2 = re.compile(r'TEST RESULT : System achieved (\d+) SQL Server TPM at (\d+) NOPM')



with open(infile, 'r') as inf:
	with open(outfile, 'w') as outf:
		vusers = None
		for line in inf:

			if not vusers:
				match = re.match(r1, line)
				if match:
					vusers = match.group(1)
			else:
				match = re.match(r2, line)
				if match:
					data = "{0}\t{1}\t{2}".format(vusers, match.group(1), match.group(2))
					outf.write(data+'\n')
					print data
				vusers = None
import glob, re, os

###
# This program is good for parsing the raw log files if one is unable to get the direct output from the Autopilot window.
###

# Settings
indir = '119'
outfile = 'out.data.txt'
# /Settings

r1 = re.compile(r'Vuser \d+:(\d+) Virtual Users configured')
r2 = re.compile(r'Vuser \d+:TEST RESULT : System achieved (\d+) SQL Server TPM at (\d+) NOPM')

os.chdir(indir)
files = glob.glob('hammerdb*')

with open(outfile, 'w') as outf:
	for f in files:
		with open(f, 'r') as inf:
			vusers = None
			for line in inf:
				if not vusers:
					match = re.match(r1, line)
					if match:
						vusers = match.group(1)
				else:
					match = re.match(r2, line)
					if match:
						data = "{0}\t{1}\t{2}".format(vusers, match.group(1), match.group(2))
						outf.write(data+'\n')
						print data
					vusers = None

以上是关于python HammerDB自动驾驶仪日志解析器的主要内容,如果未能解决你的问题,请参考以下文章

GKE 自动驾驶仪根本没有扩展

如何在 GKE 自动驾驶仪中基于自定义指标实现水平自动缩放

特斯拉希望更多的员工参与自动驾驶仪硬件测试

在 terraform 中设置 gke 自动驾驶仪的好例子

舵机控制原理

满足自动驾驶远程遥控的线控底盘整车控制器VCU