1 Star 0 Fork 50

Lasting/Ark-workload

forked from xliu/Ark-workload 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
run_pgo-20240103.sh 19.15 KB
一键复制 编辑 原始数据 按行查看 历史
lixingfu 提交于 2024-01-04 09:14 . update
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574
#!/bin/bash
sdk_path=~/workspace/daily/dev/code
toolspath=./toolspath.txt
tools_type="dev"
# ts_path=ts-swift-workload
ts_path=ts-swift-workload
code_ts_lib="BenchmarkMeasure"
target_path=""
current_path=$(pwd)
echo $current_path
# if [ -s "$toolspath" ]; then
# while IFS= read -r line; do
# case $line in
# *--ts-tools-path\ *)
# sdk_path="${line#*--ts-tools-path\ }"
# ;;
# *--ark_js_vm\ *)
# ark_js_vm="${line#*--ark_js_vm\ }"
# ;;
# *--es2abc\ *)
# es2abc="${line#*--es2abc\ }"
# ;;
# *--ark_aot_compiler\ *)
# ark_aot_compiler="${line#*--ark_aot_compiler\ }"
# ;;
# *--tools-type\ *)
# tools_type="${line#*--tools-type\ }"
# ;;
# *--case-path\ *)
# ts_path="${line#*--case-path\ }"
# ;;
# esac
# done < "toolspath.txt"
# fi
# 将带“~”的路径转换成绝对路径,保证脚本获取路径的准确性,部分命令不能使用“~”
# evaluated_path=$("echo $sdk_path")
# sdk_path=$(realpath "$evaluated_path")
arg_name=""
true="true"
false="false"
run_count=1
aarch64=""
date=$(date +'%Y%m%d%H%M%S')
code_v=1
pgo2path="${current_path}/pgo_build/${date}"
function help_explain(){
echo "[--help,--h]"
echo "[--run-count <count>]"
echo "[--case <case-name>]"
echo "[--date <date>]"
echo "[--build]"
echo "[--excel]"
echo "[--aarch64]"
echo "[--code-v] <code_path>"
}
if [ -z "$1" ]; then
echo "No input provided."
else
for arg in "$@"; do
case $arg_name in
"--case")
arg_name=""
case_name=$arg
;;
"--date")
arg_name=""
date=$arg
;;
"--run-count")
arg_name=""
run_count=$arg
;;
"--code-v")
arg_name=""
echo $arg
ts_path=$arg
pgo2path="${current_path}/pgo_build-${ts_path}/${date}"
case $arg in
"0")
ts_path=daily
pgo2path="${current_path}/pgo_build-${ts_path}/${date}"
;;
"1")
ts_path=ts-swift-workload
pgo2path="${current_path}/pgo_build/${date}"
;;
"ts-swift-workload")
ts_path=ts-swift-workload
pgo2path="${current_path}/pgo_build/${date}"
;;
"2")
ts_path=mix-case
pgo2path="${current_path}/pgo_build-${ts_path}/${date}"
;;
"3")
ts_path=weekly_workload
pgo2path="${current_path}/pgo_build-${ts_path}/${date}"
;;
esac
;;
esac
case $arg in
"--h")
help_explain
exit
;;
"--help")
help_explain
exit
;;
"--build")
build="true"
;;
"--case")
arg_name=$arg
;;
"--date")
arg_name=$arg
;;
"--excel")
excel="true"
;;
"--run-count")
arg_name=$arg
;;
"--aarch64")
aarch64=--compiler-target-triple=aarch64-unknown-linux-gnu
;;
"--code-v")
arg_name=$arg
;;
esac
done
fi
if [ ! -d $pgo2path ];then
mkdir -p $pgo2path
fi
echo "" >> ${pgo2path}/log.log
case $tools_type in
"dev")
target_path=x64.release
;;
"rk3568")
target_path=rk3568/clang_x64
;;
"hispark_taurus")
target_path=hispark_taurus/clang_x64
;;
esac
# user_lib=${sdk_path}/out/${target_path}/lib.unstripped
user_lib=${sdk_path}/out/${target_path}
# user_exe=${sdk_path}/out/${target_path}/exe.unstripped
user_exe=${sdk_path}/out/${target_path}
export LD_LIBRARY_PATH=${user_lib}/arkcompiler/ets_runtime:${user_lib}/thirdparty/icu:${user_lib}/thirdparty/zlib:${user_lib}/thirdparty/cjson:${sdk_path}/prebuilts/clang/ohos/linux-x86_64/llvm/lib
echo " \
export LD_LIBRARY_PATH=${user_lib}/arkcompiler/ets_runtime:${user_lib}/thirdparty/icu:${user_lib}/thirdparty/zlib:${user_lib}/thirdparty/cjson:${sdk_path}/prebuilts/clang/ohos/linux-x86_64/llvm/lib \
" >> ${pgo2path}/log.log
es2abc=${user_exe}/arkcompiler/ets_frontend/es2abc
ark_aot_compiler=${user_exe}/arkcompiler/ets_runtime/ark_aot_compiler
ark_js_vm=${user_exe}/arkcompiler/ets_runtime/ark_js_vm
chmod a+x ${es2abc}
chmod a+x ${ark_aot_compiler}
chmod a+x ${ark_js_vm}
echo " \
chmod a+x ${es2abc} \
" >> ${pgo2path}/log.log
echo " \
chmod a+x ${ark_aot_compiler} \
" >> ${pgo2path}/log.log
echo " \
chmod a+x ${ark_js_vm} \
" >> ${pgo2path}/log.log
$es2abc $sdk_path/arkcompiler/ets_runtime/ecmascript/ts_types/lib_ark_builtins.d.ts --type-extractor --type-dts-builtin --module --merge-abc --extension=ts --output $sdk_path/arkcompiler/ets_runtime/ecmascript/ts_types/lib_ark_builtins.d.abc
case_id=0
code_ts_filesInfo_files=($(find $ts_path -type f -name "fileInfo.txt" -exec dirname {} \;))
for filesInfo_file in "${code_ts_filesInfo_files[@]}"; do
cd ${current_path}
is_ts=($(echo ${filesInfo_file} | grep "ts"))
if [[ $is_ts == $filesInfo_file ]];then
echo ${filesInfo_file}
directory_name=$(basename $is_ts)
echo ${directory_name}
cd ${filesInfo_file}/
echo "---------------------------- ${filesInfo_file} ---------------------------" >> ${pgo2path}/log.log
((case_id++))
echo case name: ${directory_name}, case_id: ${case_id} >> ${pgo2path}/log.log
echo "-----------------------------es2abc------------------------------" >> ${pgo2path}/log.log
mapfile -t childs_ts < <(find . -type f -name "*.ts")
for child_ts in "${childs_ts[@]}"; do
echo "----- ${child_ts_dir} --------"
child_ts_dir=$(dirname "${child_ts}")
child_ts_name=$(basename $child_ts | cut -f1 -d '.')
if [[ "${child_ts_name}" == "${directory_name}" ]];then
continue
fi
cd $child_ts_dir
if [ ! -d $pgo2path/$child_ts_dir ];then
mkdir -p $pgo2path/$child_ts_dir
fi
${es2abc} $child_ts_name.ts \
--target-api-version=10 \
--type-extractor \
--module \
--merge-abc \
--extension=ts \
--output $pgo2path/$child_ts_dir/$child_ts_name.abc 2>&1 | tee -a ${pgo2path}/log.log
echo "----- child_ts : ${child_ts} , child_ts_dir : ${child_ts_dir} , child_ts_name : ${child_ts_name} ---------"
cd -
done
${es2abc} $directory_name.ts \
--target-api-version=10 \
--type-extractor \
--module \
--merge-abc \
--extension=ts \
--output ${pgo2path}/${directory_name}.abc 2>&1 | tee -a ${pgo2path}/log.log
# continue
cd ${current_path}
cd ${pgo2path}
echo "------------- ark_js_vm ----------"
${ark_js_vm} \
--log-level=info \
--enable-pgo-profiler=true \
--compiler-opt-inlining=true \
--compiler-pgo-profiler-path=./${directory_name}.ap \
--asm-interpreter=true \
--entry-point=${directory_name} \
${directory_name}.abc 2>&1 | tee -a ${pgo2path}/log.log
echo "-----------------------------ark_js_vm------------------------------" 2>&1 | tee -a ${pgo2path}/log.log
echo " \
${ark_js_vm} \
--log-level=info \
--enable-pgo-profiler=true \
--compiler-opt-inlining=true \
--compiler-pgo-profiler-path=./${directory_name}.ap \
--asm-interpreter=true \
--entry-point=${directory_name} \
${directory_name}.abc \
" >> ${pgo2path}/log.log
echo "------------- ark_aot_compiler ----------"
${ark_aot_compiler} \
--log-level=info \
--compiler-opt-loop-peeling=true \
--compiler-fast-compile=false \
--compiler-opt-inlining=true \
--compiler-max-inline-bytecodes=45 \
--builtins-dts=${sdk_path}/arkcompiler/ets_runtime/ecmascript/ts_types/lib_ark_builtins.d.abc \
--compiler-pgo-profiler-path=./${directory_name}.ap \
--aot-file=./${directory_name} \
${directory_name}.abc 2>&1 | tee -a ${pgo2path}/log.log
echo "-----------------------------ark_aot_compiler------------------------------" 2>&1 | tee -a ${pgo2path}/log.log
echo " \
${ark_aot_compiler} \
--log-level=info \
--compiler-opt-loop-peeling=true \
--compiler-fast-compile=false \
--compiler-opt-inlining=true \
--compiler-max-inline-bytecodes=45 \
--builtins-dts=${sdk_path}/arkcompiler/ets_runtime/ecmascript/ts_types/lib_ark_builtins.d.abc \
--compiler-pgo-profiler-path=./${directory_name}.ap \
--aot-file=./${directory_name} \
${directory_name}.abc \
" >> ${pgo2path}/log.log
${ark_js_vm} \
--log-level=info \
--enable-pgo-profiler=true \
--compiler-opt-inlining=true \
--compiler-pgo-profiler-path=./${directory_name}.ap \
--asm-interpreter=true \
--aot-file=./${directory_name} \
--entry-point=${directory_name} \
${directory_name}.abc 2>&1 | tee -a ${pgo2path}/log.log
# --icu-data-path ${sdk_path}/third_party/icu/ohos_icu4j/data
# --asm-interpreter=true
echo "-----------------------------ark_js_vm------------------------------" >> ${pgo2path}/log.log
echo " \
${ark_js_vm} \
--log-level=info \
--enable-pgo-profiler=true \
--compiler-opt-inlining=true \
--compiler-pgo-profiler-path=./${directory_name}.ap \
--asm-interpreter=true \
--aot-file=./${directory_name} \
--entry-point=${directory_name} \
${directory_name}.abc \
" >> ${pgo2path}/log.log
${ark_aot_compiler} \
--log-level=info \
--compiler-opt-loop-peeling=true \
--compiler-fast-compile=false \
--compiler-opt-inlining=true \
--compiler-max-inline-bytecodes=45 \
--builtins-dts=${sdk_path}/arkcompiler/ets_runtime/ecmascript/ts_types/lib_ark_builtins.d.abc \
--compiler-pgo-profiler-path=./${directory_name}.ap \
${aarch64} \
--aot-file=./${directory_name} \
${directory_name}.abc 2>&1 | tee -a ${pgo2path}/log.log
echo "-----------------------------ark_aot_compiler------------------------------" >> ${pgo2path}/log.log
echo " \
${ark_aot_compiler} \
--log-level=info \
--compiler-opt-loop-peeling=true \
--compiler-fast-compile=false \
--compiler-opt-inlining=true \
--compiler-max-inline-bytecodes=45 \
--builtins-dts=${sdk_path}/arkcompiler/ets_runtime/ecmascript/ts_types/lib_ark_builtins.d.abc \
--compiler-pgo-profiler-path=./${directory_name}.ap \
${aarch64} \
--aot-file=./${directory_name} \
${directory_name}.abc \
" >> ${pgo2path}/log.log
echo " " >> ${pgo2path}/log.log
cd ${current_path}
fi
done
# exit
cd ${current_path}
function build_pgo(){
local ts_file=$1
local file_name=$2
local abc_file=${file_name}.abc
echo "${ts_file}"
is_ts=false
for filesInfo_file in "${code_ts_filesInfo_files[@]}"; do
file=($(echo ${filesInfo_file} | grep "ts"))
echo " ---------------- ${ts_file} ${file} -----------------------"
# if echo "$file" | grep -q "$ts_file" ;then
if [[ "$file" == *"$ts_file"* ]];then
echo " ---------------- if ${ts_file} ${file} break -----------------------"
is_ts=true
break
fi
done
if [[ ${is_ts} == true ]];then
echo "is true"
return
fi
echo " " >> log.log
echo "-----------------------------build------------------------------" >> ${pgo2path}/log.log
((case_id++))
echo case name: ${directory_name}, case_id: ${case_id} >> ${pgo2path}/log.log
echo "build : ${ts_file} to ${pgo2path}" >> ${pgo2path}/log.log
${es2abc} ${ts_file} \
--target-api-version=10 \
--type-extractor \
--module \
--merge-abc \
--extension=ts \
--output ${pgo2path}/${file_name}.abc 2>&1 | tee -a ${pgo2path}/log.log
echo "------------------------es2abc----------------------------" >> ${pgo2path}/log.log
echo " \
${es2abc} ${ts_file} \
--target-api-version=10 \
--type-extractor \
--module \
--merge-abc \
--extension=ts \
--output ${pgo2path}/${file_name}.abc \
" >> ${pgo2path}/log.log
if [ "${code_ts_lib}" == "${file_name}" ];then
echo "code_ts_lib: ${code_ts_lib} : file_name:${file_name}" >> ${pgo2path}/log.log
return 1
fi
cd ${pgo2path}
${ark_js_vm} \
--log-level=info \
--enable-pgo-profiler=true \
--compiler-opt-inlining=true \
--compiler-pgo-profiler-path=./${file_name}.ap \
--asm-interpreter=true \
--entry-point=${file_name} \
${abc_file} 2>&1 | tee -a ${pgo2path}/log.log
# --icu-data-path ${sdk_path}/third_party/icu/ohos_icu4j/data
# --asm-interpreter=true
echo "------------------------ark_js_vm----------------------------" >> ${pgo2path}/log.log
echo " \
${ark_js_vm} \
--log-level=info \
--enable-pgo-profiler=true \
--compiler-opt-inlining=true \
--compiler-pgo-profiler-path=./${file_name}.ap \
--asm-interpreter=true \
--entry-point=${file_name} \
${abc_file} \
" >> ${pgo2path}/log.log
${ark_aot_compiler} \
--log-level=info \
--compiler-opt-loop-peeling=true \
--compiler-fast-compile=false \
--compiler-opt-inlining=true \
--compiler-max-inline-bytecodes=45 \
--builtins-dts=${sdk_path}/arkcompiler/ets_runtime/ecmascript/ts_types/lib_ark_builtins.d.abc \
--compiler-pgo-profiler-path=./${file_name}.ap \
--aot-file=./${file_name} \
${abc_file} 2>&1 | tee -a ${pgo2path}/log.log
echo "------------------------ark_aot_compiler----------------------------" >> ${pgo2path}/log.log
echo " \
${ark_aot_compiler} \
--log-level=info \
--compiler-opt-loop-peeling=true \
--compiler-fast-compile=false \
--compiler-opt-inlining=true \
--compiler-max-inline-bytecodes=45 \
--builtins-dts=${sdk_path}/arkcompiler/ets_runtime/ecmascript/ts_types/lib_ark_builtins.d.abc \
--compiler-pgo-profiler-path=./${file_name}.ap \
--aot-file=./${file_name} \
${abc_file} \
" >> ${pgo2path}/log.log
${ark_js_vm} \
--log-level=info \
--enable-pgo-profiler=true \
--compiler-opt-inlining=true \
--compiler-pgo-profiler-path=./${file_name}.ap \
--asm-interpreter=true \
--aot-file=./${file_name} \
--entry-point=${file_name} \
${abc_file} 2>&1 | tee -a ${pgo2path}/log.log
echo "------------------------ark_js_vm----------------------------" >> ${pgo2path}/log.log
echo " \
${ark_js_vm} \
--log-level=info \
--enable-pgo-profiler=true \
--compiler-opt-inlining=true \
--compiler-pgo-profiler-path=./${file_name}.ap \
--asm-interpreter=true \
--aot-file=./${file_name} \
--entry-point=${file_name} \
${abc_file} \
" >> ${pgo2path}/log.log
${ark_aot_compiler} \
--log-level=info \
--compiler-opt-loop-peeling=true \
--compiler-fast-compile=false \
--compiler-opt-inlining=true \
--compiler-max-inline-bytecodes=45 \
--builtins-dts=${sdk_path}/arkcompiler/ets_runtime/ecmascript/ts_types/lib_ark_builtins.d.abc \
--compiler-pgo-profiler-path=./${file_name}.ap \
${aarch64} \
--aot-file=./${file_name} \
${abc_file} 2>&1 | tee -a ${pgo2path}/log.log
echo "------------------------ark_aot_compiler----------------------------" >> ${pgo2path}/log.log
echo " \
${ark_aot_compiler} \
--log-level=info \
--compiler-opt-loop-peeling=true \
--compiler-fast-compile=false \
--compiler-opt-inlining=true \
--compiler-max-inline-bytecodes=45 \
--builtins-dts=${sdk_path}/arkcompiler/ets_runtime/ecmascript/ts_types/lib_ark_builtins.d.abc \
--compiler-pgo-profiler-path=./${file_name}.ap \
${aarch64} \
--aot-file=./${file_name} \
${abc_file} \
" >> ${pgo2path}/log.log
echo " " >> ${pgo2path}/log.log
cd ${current_path}
}
cd ${current_path}
function run_pgo(){
if [ "${code_ts_lib}" == "${file_name}" ];then
echo "code_ts_lib: ${code_ts_lib} : file_name:${file_name}"
return 1
fi
cd ${pgo2path}
local file_name=$1
local abc_file=${pgo2path}/${file_name}.abc
echo run ${file_name}
${ark_js_vm} --entry-point=${file_name} --aot-file=./${pgo2path}/${file_name} ${abc_file}
cd -
}
function run(){
if [[ "$build" = "true" ]]; then
code_ts_lib_file=$(find $ts_path -type f -name ${code_ts_lib}.ts)
if [ "${code_ts_lib_file}" != "" ]; then
file_name=$(basename "${code_ts_lib_file}" | cut -f1 -d'.')
pgo_build_path=$(dirname "${pgo2path}")
${es2abc} ${code_ts_lib_file} --type-extractor --module --merge-abc --extension=ts --output ${pgo_build_path}/${file_name}.abc
fi
if [ -z "$case_name" ]; then
txt_files=($(find $ts_path -type f -name "*.ts"))
for file in "${txt_files[@]}"; do
echo " --------Content of $file:"
local ts_file_path=$file
local file_name=$(basename "${file}" | cut -f1 -d'.')
build_pgo ${ts_file_path} ${file_name}
if [[ "$excel" = "true" ]]; then
if [ "${code_ts_lib}" == "${file_name}" ];then
echo "code_ts_lib: ${code_ts_lib} : file_name:${file_name}"
continue
fi
python pgo2excel.py --case-dir $pgo2path --run-case $file_name --run-count $run_count --ark_js_vm $ark_js_vm
fi
done
else
local ts_file_path=$(find ${ts_path} -name "${case_name}.ts")
local file_name=$(basename "$ts_file_path" | cut -f1 -d'.')
if [ -f "${ts_file_path}" ]; then
build_pgo ${ts_file_path} ${file_name}
if [[ "$excel" = "true" ]]; then
if [ "${code_ts_lib}" == "${file_name}" ];then
echo "code_ts_lib: ${code_ts_lib} : file_name:${file_name}"
continue
fi
python pgo2excel.py --case-dir $pgo2path --run-case $file_name --run-count $run_count --ark_js_vm $ark_js_vm
fi
fi
fi
fi
if [ ! -d $pgo2path ];then
echo "${pgo2path} No such file or directory"
exit
fi
}
run
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
TypeScript
1
https://gitee.com/lastingman/ark-workload.git
[email protected]:lastingman/ark-workload.git
lastingman
ark-workload
Ark-workload
master

搜索帮助