代码拉取完成,页面将自动刷新
#!/bin/bash
# 检测依赖软件是否已经安装
function check_dependency() {
check_common_dependency
if ! type create_gcov &>/dev/null; then
echo "[ERROR] Optimization mode ${opt_mode} but autofdo is missing, try 'yum install autofdo'."
exit 1
fi
}
# 根据模式选择Wrapper或者Bear模式构建
function prepare_env() {
case ${build_mode} in
"Wrapper")
create_wrapper
;;
"Bear")
export COMPILATION_OPTIONS="-g"
export LINK_OPTIONS="-g"
;;
*)
echo "[ERROR] Build mode ${build_mode} is not supported, the value is : Wrapper/Bear"
exit 1
;;
esac
}
# 创建原始wrapper
function create_wrapper() {
echo "[INFO] Start generating the original wrapper."
echo "${compiler_path}/bin/${c_compiler} -g \"\$@\"" >${compiler_wrapper}/${c_compiler}
echo "${compiler_path}/bin/${cxx_compiler} -g \"\$@\"" >${compiler_wrapper}/${cxx_compiler}
post_create_wrapper
}
# 执行perf采样,生成profile文件
function profiling () {
echo "[INFO] Start perf record by ${opt_mode} and generate a profile file."
process_id=$(pidof ${application_name})
get_arch=$(arch)
if [[ ${get_arch} =~ "x86_64" ]]; then
perf_event="inst_retired.prec_dist:u,cache-misses:u"
gcov_file_name="${profile_data_path}/${gcov_name}.inst_retired.prec_dist:u"
elif [[ ${get_arch} =~ "aarch64" ]]; then
perf_event="inst_retired:u,cache-misses:u"
gcov_file_name="${profile_data_path}/${gcov_name}.inst_retired:u"
else
echo "[ERROR] Unsupport arch: ${get_arch}"
exit 1
fi
perf record -e ${perf_event} -o ${profile_data_path}/${profile_name} -p ${process_id} -- sleep ${perf_time} >>${log_file} 2>&1
is_file_exist "${profile_data_path}/${profile_name}"
create_gcov --binary=${bin_file} --profile=${profile_data_path}/${profile_name} --gcov=${profile_data_path}/${gcov_name} --gcov_version=1 --use_lbr=0 >>${log_file} 2>&1
is_file_exist "${gcov_file_name}"
is_file_exist "${profile_data_path}/${gcov_name}.cache-misses:u"
pkill ${application_name}
}
# 根据模式选择Wrapper或者Bear模式构建
function prepare_new_env() {
case ${build_mode} in
"Wrapper")
create_new_wrapper
;;
"Bear")
export COMPILATION_OPTIONS="-fauto-profile=${gcov_file_name} -fcache-misses-profile=${profile_data_path}/${gcov_name}.cache-misses:u -fprefetch-loop-arrays=2"
;;
*)
echo "[ERROR] Build mode ${build_mode} is not supported, the value is : Wrapper/Bear"
exit 1
;;
esac
}
#生成新的wrapper
function create_new_wrapper() {
echo "[INFO] Start to generate a new wrapper."
echo "${compiler_path}/bin/${c_compiler} -fauto-profile=${gcov_file_name} -fcache-misses-profile=${profile_data_path}/${gcov_name}.cache-misses\:u -fprefetch-loop-arrays=2 \"\$@\"" >${compiler_wrapper}/${c_compiler}
echo "${compiler_path}/bin/${cxx_compiler} -fauto-profile=${gcov_file_name} -fcache-misses-profile=${profile_data_path}/${gcov_name}.cache-misses\:u -fprefetch-loop-arrays=2 \"\$@\"" >${compiler_wrapper}/${cxx_compiler}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。