profile.sh 493 字节
Newer Older
Q
qijun 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
#!/bin/bash

book_dir=/book
work_dir=/book/.tools/profile
pushd $book_dir
array=()
while IFS=  read -r -d $'\0'; do
    array+=("$REPLY")
done < <(find ${book_dir} -name train.py -print0)

for file in "${array[@]}"; do
    echo $file
    dir=$(dirname "${file}")
    result=${file%.*}'.prof'
    result_png=${result}'.png'
    pushd $dir
    python -m cProfile -o $result $file
    popd
    ${work_dir}/get_stats.py $result
    gprof2dot -f pstats $result | dot -Tpng -o $result_png
done
popd