代码拉取完成,页面将自动刷新
同步操作将从 xliu/Ark-workload 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
import os
from openpyxl import load_workbook,Workbook
import sys
ark_js_vm=""
arguments = sys.argv
run_count = 1
for i in range(len(arguments)):
if arguments[i] == '--case-dir':
pgo2path=arguments[i+1]
Date = pgo2path[pgo2path.rfind('/') + 1:]
if arguments[i] == '--run-count':
run_count = int(arguments[i+1])
if arguments[i] == '--run-case':
name=arguments[i+1]
if arguments[i] == '--ark_js_vm':
ark_js_vm=arguments[i+1]
if ark_js_vm=="":
print("please pass in the ark_js_vm path")
sys.exit()
def variable_exists(var_name):
try:
exec(var_name)
except NameError:
return False
else:
return True
if not variable_exists("pgo2path"):
sys.exit()
def runCmd(cmd):
result = os.popen(cmd).read()
print(cmd)
print(result+"\n\n")
with open(f"pgo_{Date}_log.txt", "a") as file:
file.writelines(cmd+"\n")
with open(f"pgo_{Date}_log.txt", "a") as file:
file.writelines(result+"\n")
return result
def is_excel_sheet_empty(file_path, sheet_name):
try:
workbook = load_workbook(filename=file_path)
sheet = workbook[sheet_name]
if sheet.max_row == 1 and sheet.max_column == 1 and sheet.cell(row=1, column=1).value is None:
return True
else:
return False
except Exception as e:
print(f"An error occurred: {str(e)}")
return None
def is_excel_file_exists(file_path):
try:
workbook = load_workbook(filename=file_path)
return True
except FileNotFoundError:
return False
def run():
print("---------------------------------------")
if not is_excel_file_exists(f'pgo_data_{Date}.xlsx'):
workbook = Workbook()
sheet = workbook.active
data = ["case"]
for i in range(run_count):
data.append(f"data{i}")
data.append(f"average")
sheet.append(data)
sheet2 = workbook.create_sheet(title="Sheet2")
sheet2['A1'] = 'case'
sheet2['B1'] = 'average'
workbook.save(f'pgo_data_{Date}.xlsx')
workbook = load_workbook(f'pgo_data_{Date}.xlsx')
sheet = workbook['Sheet']
sheet2 = workbook['Sheet2']
with open(f"pgo_{Date}_error.txt", "w") as file:
pass
print(name)
test_data = {}
with open(f"pgo_{Date}_log.txt", "a") as file:
file.writelines(name+"\n")
with open(f"pgo_{Date}_error.txt", "a") as file:
file.writelines(name+"\n")
for i in range(run_count):
cmd = f"cd {pgo2path} && {ark_js_vm} --entry-point={name} --aot-file=./{name} {name}.abc"
result = runCmd(cmd)
if "error" in result or "Signal" in result or "TypeError" in result or "RangeError" in result:
with open(f"pgo_{Date}_error.txt", "a") as file:
file.writelines(f"{result}\n")
print(f"result error: {result}")
continue
result = result.split("\n")
print(f"result: {result}")
for value in result:
data = value
if " ms = " in value:
value=value.replace(":","")
value = value.split(" ms = ")
elif ": \t" in value and "ms" in value:
value=value.replace(" : ","")
value=value.replace(": ","")
value = value.split("\t")
elif ": " in value and "ms" in value:
value=value.replace(": ","\t")
value=value.replace(": ","")
value = value.split("\t")
elif " : " in value and "ms" in value:
value=value.replace(" : ","\t")
value = value.split("\t")
elif ":" in value and "ms" in value:
value=value.replace(":","")
value = value.split("\t")
elif " - " in value or "Splay:" in value:
value=value.replace(":","")
value = value.split("\t")
elif "usec = " in value:
value = value.split(": usec = ")
else:
continue
with open(f"data_{Date}.txt", "a") as file:
file.writelines(data+"\n")
if not value[0] in test_data:
test_data[value[0]] = []
test_data[value[0]].append(value[1])
print(test_data)
for itme in test_data:
data = []
data.append(itme)
sum = 0
for value in test_data[itme]:
data.append(round(float(value),3))
sum += round(float(value),3)
average=round(sum/len(test_data[itme]),3)
data.append(average)
sheet.append(data)
sheet2.append([itme,average])
workbook.save(f'pgo_data_{Date}.xlsx')
print("---------------------------------------\n")
run()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。