本文整理匯總了Python中result.Result.name方法的典型用法代碼示例。如果您正苦於以下問題:Python Result.name方法的具體用法?Python Result.name怎麽用?Python Result.name使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類result.Result
的用法示例。
在下文中一共展示了Result.name方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: parse_record
# 需要導入模塊: from result import Result [as 別名]
# 或者: from result.Result import name [as 別名]
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