1#!/bin/bash 2# Copyright (c) 2023 Huawei Device Co., Ltd. 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15set -e 16build() { 17 cd ${benchmarks_path}/../ 18 rm -rf build/ 19 mkdir build 20 cd build 21 cmake .. -DFFRT_BENCHMARKS=ON -DCMAKE_BUILD_TYPE=Release 22 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:. 23 make -j ffrt 24 make -j 25} 26 27run_all() { 28 task_compute_time_tbl=(0 5 10 15 20 25 30 35 40 50 60 70 80 90 100 120 140 160 180 200) 29 export FIB_NUM=20 30 export REPEAT=$2 31 is_first=1 32 for task_compute_time in ${task_compute_time_tbl[@]}; do 33 export COMPUTE_TIME_US=$task_compute_time 34 { 35 echo "export FIB_NUM=$FIB_NUM; export COMPUTE_TIME_US=$COMPUTE_TIME_US; REPEAT=$REPEAT" 36 ./benchmarks/fork_join 37 ./benchmarks/fib 38 ./benchmarks/face_story 39 ./benchmarks/base 40 } | tee $output_dir/perf_$1_${task_compute_time}.log 41 if [ "$is_first" == "1" ]; then 42 echo repeat,task_compute_time,\ 43 $(grep -w us $output_dir/perf_$1_${task_compute_time}.log | awk '{print $2}' | tr '\n' ',') >> $output_dir/perf_$1.csv 44 is_first=0 45 fi 46 echo $REPEAT,$task_compute_time,\ 47 $(grep -w us $output_dir/perf_$1_${task_compute_time}.log | awk '{print $3}' | tr '\n' ',') >> $output_dir/perf_$1.csv 48 done | tee $output_dir/perf_$1_.log 49 touch $output_dir/perf_$1.csv 50} 51 52# create dir 53cd $(dirname $0) 54benchmarks_path=$(pwd) 55stamp=$(git log --date=format:'%Y_%m_%d_%H_%M_%S' -1 | grep Date | sed -E 's/[^0-9]*([0-9_]*)/\1/g') 56output_dir=${benchmarks_path}/output/tag_$stamp 57rm -rfd $output_dir 58mkdir -m 777 -p $output_dir 59 60# build 61export TOOLCHAIN_PATH=../../../../../prebuilts/clang/host/linux-x86/clang-r416183b1 62export PATH=$TOOLCHAIN_PATH/bin:$PATH 63export LD_LIBRARY_PATH=$TOOLCHAIN_PATH/lib64:$LD_LIBRARY_PATH 64build 65 66# benchmark 67export REPEAT=1;export PREHOT_FFRT=1;export FFRT_LOG_LEVEL=0 68exec_times=${1:-'1'} 69 70echo 1 > ../ffrt.cfg && run_all thread1 ${exec_times} 71echo 8 > ../ffrt.cfg && run_all thread8 ${exec_times} 72 73cp "$benchmarks_path/base.csv" "$output_dir" 74MPLBACKEND=svg "$benchmarks_path/plot.py" "$output_dir" "benchmark_${stamp}.svg" 75