1 Star 0 Fork 0

jinqi zhang/riscv_istio_test

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
performance_counter_920.sh 3.56 KB
一键复制 编辑 原始数据 按行查看 历史
jinqi zhang 提交于 2024-12-01 20:14 . bug fix
#!/bin/bash
# $1: Complete execution command $2: store folder for generated file
# eg: ./performance_counter.sh "./hackbench -s 512 -l 200 -g 15 -f 25 -P" /home
if [ $# -ne 2 ]; then
echo "Usage: ./performance_counter.sh parameter1 parameter2"
exit 1
fi
echo "parameter1=$1"
result=$(echo "$1" | grep -oP '(?<=\s)\./\S*')
pkg2=$(echo "$result" | sed 's|^\./||' | sed 's/\//_/g')
result1=$(echo "$1" | sed 's:.*/::')
result2=$(echo "$1" | sed 's/.*^\(.*\)\$.*/\1/')
file_name="$result2-$pkg2"
echo "file name : $file_name"
echo "path: $result"
# 检查文件是否存在于目标文件夹中
if [ -f "$2/$file_name.txt" ]; then
echo "$file_name.txt already exists in $2. Skipping test."
exit 0
fi
if [ -f "performance.txt" ]; then
rm -f performance.txt
echo "performance.txt has been deleted"
fi
perf stat --sync -e duration_time,task-clock,cycles,instructions,cache-references,cache-misses,branches,branch-misses,L1-dcache-loads,L1-dcache-load-misses,LLC-load-misses,LLC-loads -r 1 -o performance.txt $1
awk '{print $1, $2, $3}' performance.txt > performance_tmp.txt
mv performance_tmp.txt performance.txt
duration_time=$(grep "duration_time" performance.txt | awk '{print $1}' | sed 's/,//g')
task_clock=$(grep "task-clock" performance.txt | awk '{print $1}' | sed 's/,//g')
cpu_cycle=$(grep "cycles" performance.txt | awk '{print $1}' | sed 's/,//g')
instruction=$(grep "instructions" performance.txt | awk '{print $1}' | sed 's/,//g')
cache_references=$(grep "cache-references" performance.txt | awk '{print $1}' | sed 's/,//g')
cache_misses=$(grep "cache-misses" performance.txt | awk '{print $1}' | sed 's/,//g')
branches=$(grep "branches" performance.txt | awk '{print $1}' | sed 's/,//g')
branch_misses=$(grep "branch-misses" performance.txt | awk '{print $1}' | sed 's/,//g')
L1_dcache_loads=$(grep "L1-dcache-loads" performance.txt | awk '{print $1}' | sed 's/,//g')
L1_dcache_load_misses=$(grep "L1-dcache-load-misses" performance.txt | awk '{print $1}' | sed 's/,//g')
LLC_load_misses=$(grep "LLC-load-misses" performance.txt | awk '{print $1}' | sed 's/,//g')
LLC_loads=$(grep "LLC-loads" performance.txt | awk '{print $1}' | sed 's/,//g')
printf "\n\n"
echo "Avg 10 times duration time: $duration_time"
printf "Avg 10 times task clock: %.3f\n" $task_clock
echo "Avg 10 times cpu-cycles: $cpu_cycle"
echo "Avg 10 times instructions: $instruction"
echo "Avg 10 times cache references: $cache_references"
echo "Avg 10 times cache misses: $cache_misses"
echo "Avg 10 times branches: $branches"
echo "Avg 10 times branch misses: $branch_misses"
echo "Avg 10 times L1 dcache loads: $L1_dcache_loads"
echo "Avg 10 times L1 dcache load misses: $L1_dcache_load_misses"
echo "Avg 10 times LLC load misses: $LLC_load_misses"
echo "Avg 10 times LLC load: $LLC_loads"
IPC=$(echo "scale=3; $instruction / $cpu_cycle" | bc)
printf "Avg 10 times IPC: %.3f\n" $IPC
if [ -f "$file_name.txt" ]; then
rm -f $file_name.txt
echo "$file_name.txt has been deleted"
fi
echo "$result2" >> $file_name.txt
echo "($result)" >> $file_name.txt
echo $duration_time >> $file_name.txt
echo $task_clock >> $file_name.txt
echo $cpu_cycle >> $file_name.txt
echo $instruction >> $file_name.txt
echo $cache_references >> $file_name.txt
echo $cache_misses >> $file_name.txt
echo $branches >> $file_name.txt
echo $branch_misses >> $file_name.txt
echo $L1_dcache_loads >> $file_name.txt
echo $L1_dcache_load_misses >> $file_name.txt
echo $LLC_load_misses >> $file_name.txt
echo $LLC_loads >> $file_name.txt
printf "%.3f\n" $IPC >> $file_name.txt
mv $file_name.txt $2
printf "perf测试结束\n\n"
rm -f performance.txt
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/jasonbus_admin/riscv_istio_test.git
git@gitee.com:jasonbus_admin/riscv_istio_test.git
jasonbus_admin
riscv_istio_test
riscv_istio_test
1.22.2-riscv

搜索帮助