#!/bin/sh
set -x
cd ../../utils
. ./sys_info.sh
cd -
# 检查是否root 用户
if [ `whoami` != 'root' ] ; then
echo "You must be the superuser to run this script" >&2
exit 1
fi
安装gcc包
case $distro in
"centos")
yum install gcc -y
print_info $? install-gcc
;;
"ubuntu")
apt-get install gcc -y
print_info $? install-gcc
;;
esac
#所以这个gprof的tool就是在gcc编译的时候添加-pg 这个flag
gcc -g -pg gprof.c
print_info $? gcc-gprof.c
#运行c 函数
./a.out
print_info $? run-a.out
#输出c语言编译后的信息,主要用于优化c语言.
gprof a.out gmon.out > report.txt
print_info $? run-gprof
case $distro into
"ubuntu")
apt-get remove gcc -y
print_info $? remove-gcc
;;
"centos")
yum remove gcc -y
print_info $? remove-gcc
;;
esac
test-definitions/blob/master/auto-test/gprof/gprof.sh
最新推荐文章于 2018-01-23 08:23:01 发布