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 16 17HDC='/home/yinchuang/Task/dlopen/toolchains//hdc_std -s 10.121.251.143:8710 ' 18 19function lock_cpu() { 20 $HDC shell "mount -o rw,remount /vendor" 21 $HDC shell "rm -rf /vendor/etc/soc_perf/*" 22 $HDC shell "echo 1700000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq" 23 $HDC shell "echo 2343000 > /sys/devices/system/cpu/cpu4/cpufreq/scaling_min_freq" 24 $HDC shell "echo 3130000 > /sys/devices/system/cpu/cpu7/cpufreq/scaling_min_freq" 25 $HDC shell "echo 4-7 > /dev/cpuset/top-app/cpuset.cpus" 26 $HDC shell "echo 4-7 > /dev/cpuset/graphic/cpuset.cpus" 27 echo "current freqency: " 28 $HDC shell "cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq" 29 $HDC shell "cat /sys/devices/system/cpu/cpu1/cpufreq/scaling_cur_freq" 30 $HDC shell "cat /sys/devices/system/cpu/cpu2/cpufreq/scaling_cur_freq" 31 $HDC shell "cat /sys/devices/system/cpu/cpu3/cpufreq/scaling_cur_freq" 32 $HDC shell "cat /sys/devices/system/cpu/cpu4/cpufreq/scaling_cur_freq" 33 $HDC shell "cat /sys/devices/system/cpu/cpu5/cpufreq/scaling_cur_freq" 34 $HDC shell "cat /sys/devices/system/cpu/cpu6/cpufreq/scaling_cur_freq" 35 $HDC shell "cat /sys/devices/system/cpu/cpu7/cpufreq/scaling_cur_freq" 36 37 $HDC shell power-shell setmode 602 38} 39 40function usage() { 41 echo "usage: $0 -r {the number of runs} -p {case path in phone}" 42 exit 1 43} 44 45REPS=50 46CASE_PATH="/data/local/tmp/musl_dlopen" 47 48while getopts "hp:r:" OPT 49do 50 case "$OPT" in 51 p) CASE_PATH=$OPTARG;; 52 r) REPS=$OPTARG;; 53 h) usage;; 54 *) 55 echo "unknown options $opt" 56 usage 57 exit 1 58 ;; 59 esac 60done 61 62echo REPS:$REPS 63echo CASE_PATH:$CASE_PATH 64time=$(date "+%Y%m%d-%H%M%S") 65result_file="dlopen_cost_${time}.txt" 66 67lock_cpu 68 69for((i=1;i<=${REPS};i++)); 70do 71 $HDC shell $CASE_PATH | grep "dlopen" >> ${result_file} 72done 73 74echo "save results to dlopen_cost_${time}.txt" 75 76err=$(cat ${result_file} | grep "dlopen error" | wc -l ) 77if [ $err -gt 0 ]; 78then 79 echo "dlopen failed!!!" 80 exit 1 81fi 82 83cat ${result_file} | awk 'BEGIN{ave=0; num=0} {ave+=$4;num++} END{print "dlopen cost(ave): " ave/num "(ms)", "num:" num}' 84