shprof

来自「android-w.song.android.widget」· 代码 · 共 67 行

TXT
67
字号
#! /bin/bash## shprof - a line profiler for shell scripts## adapted from a similar program included in `The New KornShell' by# Bolsky and Korn and posted to usenet by bsh20858@challenger.fhda.edu## converted to bash v2 syntax by Chet Ramey#TMPFILE=${TMP:-/tmp}/shprof$$trap 'rm -f $TMPFILE' EXITerrexit(){	echo $0: "$@" >&2	exit 1}# create script with profiling enabledcat > $TMPFILE <<- \_EOF_	declare -a _line	_profend()	{		case "$1" in		/*|./*)	file="$1" ;;		*) file=$(type -path "$1") ;;		esac		echo "*** line profile for $file ***"		i=1;		while read -r && [ $i -le $NLINE ]; do			count=${_line[$i]}			if [ "$count" -gt 0 ]; then				echo "[$count] $i: $REPLY"			fi			i=$((i + 1))		done <$file_EOF_# make the profiling script remove itself after printing line statsecho "rm -f $TMPFILE" >> $TMPFILEcat >> $TMPFILE <<- \_EOF_	}	_command=$1	shift	i=1	NLINE=$(wc -l < "$_command")	while [ $i -le $NLINE ]; do		_line[$i]=0		i=$((i + 1))	done	unset i	trap "_profend ${_command}" EXIT	trap '_line[$LINENO]=$((${_line[$LINENO]} + 1))' DEBUG	LINENO=0_EOF_case "$1" in/*|./*)	file=$1 ;;*)	file=$((type -path "$1")) ;;esaccat "${file-$1}" >> $TMPFILE || errexit "${1}: cannot open"chmod +x $TMPFILEexec -a "$file" $TMPFILE "$@"

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?