-
Notifications
You must be signed in to change notification settings - Fork 0
/
caffe-test.sh
75 lines (62 loc) · 1.82 KB
/
caffe-test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash
set -e
start=$(date +%s)
# 下载deploy文件到caffe-deploy文件夹
mkdir caffe-deploy; cd caffe-deploy
wget https://github.com/6eanut/NOTEBOOK/raw/main/24-07/caffe/deploy/deploy.zip
unzip deploy.zip
rm deploy.zip
WORKSPACE=$(pwd)
# 下载perf_information_get.sh
wget https://raw.githubusercontent.com/6eanut/NOTEBOOK/main/24-07/caffe/shell/perf_information_get.sh
chmod +x perf_information_get.sh
mkdir perf
# 文件列表
output_files=("temp_output.txt" "output-checkout.txt" "output.txt")
# 遍历文件列表
for file in "${output_files[@]}"; do
# 检查文件是否存在
if [ -f "$file" ]; then
# 清空文件
> "$file"
echo "清空 $file"
else
echo "$file 不存在."
fi
done
# 获取所有文件名并存储在一个数组中
files=($(ls))
# 遍历从00到49的文件名
for i in {0..49}
do
# 47-*.prototxt模型需要下载数据集,要单独测试
if [ "$i" -eq 47 ]; then
continue
fi
# 构建文件名模式
pattern=$(printf "%02d-" $i)
# 使用模式从数组中查找文件名
for f in "${files[@]}"
do
if [[ $f == $pattern* ]]; then
file=$f
break
fi
done
# 检查是否找到了匹配的文件
if [ -z "$file" ]; then
echo "找不到文件: ${pattern}*"
else
# 执行caffe time命令并将最后13行输出追加到输出文件
echo ""$file"正在测试中"
./perf_information_get.sh "caffe time -model "$file"" "$WORKSPACE/perf" &> temp_output.txt
tail -n 13 temp_output.txt >> output.txt
echo "$file" >> output-check.txt
tail -n 13 temp_output.txt >> output-check.txt
rm temp_output.txt
echo ""$file"测试完成"
fi
done
end=$(date +%s)
runtime=$((end-start))
echo "脚本执行时长: $runtime s"