Exemple #1
0
def parse_record(record):
	"""
		Parses a benchmark results record
	"""

	r = Result()
	items = record.split('\n')
	for item in items:
		if 'name' in item.lower():
			name = item.split(':')[1].strip()
			r.name = name
		elif 'elapsed time' in item.lower():
			# Format is like this
			# elapsed time : 123123 seconds
			num = float(item.split(':')[1].strip().split(' ')[0])
			r.elapsed_time += num
		elif 'cpu cycles' in item.lower():
			# Format is like this
			# cpu cycles : 123123
			num = float(item.split(':')[1])
			r.cpu_cycles += num
		# This condition should be above the instructions
		# case to ensure proper parsing
		elif 'branch instructions' in item.lower():
			num = float(item.split(':')[1])
			r.branch_instructions += num
		elif 'ipc' in item.lower():
			num = float(item.split(':')[1])
			r.ipc += num
		elif 'branch misses' in item.lower():
			num = float(item.split(':')[1])
			r.branch_misses += num
		elif 'instructions' in item.lower():
			num = float(item.split(':')[1])
			r.instructions += num
		elif 'branch mispred' in item.lower():
			# Format is like this
			# branch mispred rate: 1.12312%
			percentage = item.split(':')[1]
			num = float(percentage.strip()[:-1]) # remove percentage
			r.branch_mispredict_rate += num				
		else:
			pass
	return r