mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-11-26 19:50:55 +00:00
[Codecheck] Fix jsperftest script codestyle
Issue: #IAESN1 Testing: `OHOS CI` Change-Id: I39bf669928f9998ab8f76b2fb899a7a4060415db Signed-off-by: Petrov Igor <petrov.826961@huawei.com>
This commit is contained in:
parent
d2aa3893c4
commit
45da78eba3
@ -21,7 +21,7 @@ import sys
|
||||
import re
|
||||
import os
|
||||
|
||||
help = """
|
||||
HELP = """
|
||||
python prerun_proc.py __VAR__=value ... default_js_scr.js
|
||||
|
||||
lets assume that default_js_scr.js have next lines
|
||||
@ -57,6 +57,7 @@ __MULTIPLIER__ = 3
|
||||
|
||||
"""
|
||||
|
||||
|
||||
def get_args():
|
||||
vars_to_replace = {}
|
||||
script_name = ""
|
||||
@ -71,7 +72,7 @@ def get_args():
|
||||
else:
|
||||
script_name = arg
|
||||
elif(arg == "-h" or arg == "--help"):
|
||||
print(help)
|
||||
print(HELP)
|
||||
exit(0)
|
||||
else:
|
||||
raise RuntimeError(f"{arg} is wrong argument, please look at help")
|
||||
@ -84,21 +85,23 @@ def get_args():
|
||||
|
||||
return script_name, vars_to_replace
|
||||
|
||||
|
||||
def main():
|
||||
script_name, vars_to_replace = get_args()
|
||||
data = []
|
||||
|
||||
status = os.stat(script_name)
|
||||
fd = os.open(script_name, os.O_RDWR|os.O_CREAT, status.st_mode)
|
||||
fd = os.open(script_name, os.O_RDWR | os.O_CREAT, status.st_mode)
|
||||
with os.fdopen(fd, 'r') as script_file:
|
||||
data = script_file.readlines()
|
||||
|
||||
for i in range(len(data)):
|
||||
for var in vars_to_replace:
|
||||
for i, _ in enumerate(data):
|
||||
for var in vars_to_replace.items():
|
||||
if(re.search(f"const {var} =", data[i].strip())):
|
||||
data[i]= data[i][:data[i].find("=") + 1] + ' ' + vars_to_replace[var] + ';\n'
|
||||
val = data.get(i)
|
||||
data[i] = val[:val.find("=") + 1] + ' ' + vars_to_replace.get(var) + ';\n'
|
||||
|
||||
fd = os.open(script_name, os.O_RDWR|os.O_CREAT, status.st_mode)
|
||||
fd = os.open(script_name, os.O_RDWR | os.O_CREAT, status.st_mode)
|
||||
with os.fdopen(fd, 'w') as script_file:
|
||||
script_file.seek(0)
|
||||
script_file.writelines(data)
|
||||
|
@ -208,15 +208,16 @@ def append_row_data(report_file, case_test_data):
|
||||
jis_case_file_name_with_class = Constants.JS_FILE_SUPER_LINK_DICT['/'.join([class_name, api_name])]
|
||||
js_file_super_link = '/'.join([Constants.HYPERLINK_HEAD, jis_case_file_name_with_class])
|
||||
new_row = [js_case_name, scene, excute_status, cast_to_float_or_str(exec_time), yesterday_excute_time,
|
||||
is_degraded_str,cast_to_float_or_str(v_8_excute_time),
|
||||
cast_to_float_or_str(v_8_jitless_excute_time),cast_to_float_or_str(ark_divide_v_8),
|
||||
cast_to_float_or_str(ark_divide_v_8_with_jitless),js_file_super_link, ' ']
|
||||
is_degraded_str, cast_to_float_or_str(v_8_excute_time),
|
||||
cast_to_float_or_str(v_8_jitless_excute_time), cast_to_float_or_str(ark_divide_v_8),
|
||||
cast_to_float_or_str(ark_divide_v_8_with_jitless), js_file_super_link, ' ']
|
||||
ws.append(new_row)
|
||||
check(is_degraded_str, ark_divide_v_8, ark_divide_v_8_with_jitless, ws)
|
||||
wb.save(report_file)
|
||||
return Constants.RET_OK
|
||||
|
||||
def check(is_degraded_str,ark_divide_v_8,ark_divide_v_8_with_jitless,ws):
|
||||
|
||||
def check(is_degraded_str, ark_divide_v_8, ark_divide_v_8_with_jitless, ws):
|
||||
if is_degraded_str is str(True):
|
||||
ws.cell(row=ws.max_row, column=6).fill = PatternFill(start_color='FF0000', end_color='FF0000',
|
||||
fill_type=Constants.SOLID)
|
||||
@ -230,6 +231,7 @@ def check(is_degraded_str,ark_divide_v_8,ark_divide_v_8_with_jitless,ws):
|
||||
ws.cell(row=ws.max_row, column=10).fill = PatternFill(start_color='FF00FF', end_color='FF00FF',
|
||||
fill_type=Constants.SOLID)
|
||||
|
||||
|
||||
def get_ark_js_cmd(abc_file: str) -> List[str]:
|
||||
"""Get command for ark js vm"""
|
||||
cmd: List[str] = []
|
||||
@ -270,7 +272,7 @@ def prepare_for_ark_run(class_name: str, api_name: str) -> Tuple[str, str]:
|
||||
|
||||
def run_es2panda(abc_file: str, js_file: str) -> int:
|
||||
"""Run es2panda for one benchmark file"""
|
||||
cmd = [Constants.ES2ABC_PATH, "--output", abc_file, js_file]
|
||||
cmd = [Constants.ES2ABC_PATH, "--output", abc_file, js_file]
|
||||
logger.info("run cmd: %s", cmd)
|
||||
ret = subprocess.run(cmd, check=False)
|
||||
if ret.returncode != 0:
|
||||
@ -495,6 +497,7 @@ def process_args(args: argparse.Namespace) -> argparse.Namespace:
|
||||
raise RuntimeError(f"error bad parameters --iterations: {args.iterations}")
|
||||
return args
|
||||
|
||||
|
||||
def get_args():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(
|
||||
@ -623,6 +626,7 @@ def get_yesterday_excute_times(yesterday_report):
|
||||
excute_time = ws.cell(row=row_num, column=4).value
|
||||
Constants.YESTERDAY_EXCUTE_TIME_DICT[main_key] = excute_time
|
||||
|
||||
|
||||
def update_data_by_log(data: dict, log_path: str, js_name: str) -> dict:
|
||||
"""Update execution time data by log file"""
|
||||
with open(log_path, 'r') as f:
|
||||
@ -774,6 +778,7 @@ def get_v_8_jitless_excute_times(jspath, v_8_based_report_file_path, iterations)
|
||||
|
||||
return Constants.RET_OK
|
||||
|
||||
|
||||
def hdc_send(source: str, destination: str) -> int:
|
||||
"""Run hdc send command"""
|
||||
hdc_cmd: List[str] = [Constants.HDC_PATH, "file", "send"]
|
||||
@ -787,6 +792,7 @@ def hdc_run(cmd: List[str]) -> int:
|
||||
hdc_cmd = [Constants.HDC_PATH, "shell"] + cmd
|
||||
return subprocess.run(hdc_cmd).returncode
|
||||
|
||||
|
||||
def prepare_device():
|
||||
"""Preapare device workdir for js perf testing"""
|
||||
if hdc_send(Constants.ARK_JS_VM_PATH, Constants.DEVICE_WORKDIR) != 0:
|
||||
|
Loading…
Reference in New Issue
Block a user