Merge pull request #350 from taoliu/fix_test_signal_py38_dev
[MACS.git] / test / prockreport
blob708e277ae3a8041d9fe8d1da5474142d1f11e3ee
1 #!/bin/bash
2 # modified from prockmon
4 unset LD_LIBRARY_PATH
6 if [[ $# < 2 ]];then
7 echo 'Check total CPU time and maximum memory usage of a process.'
8 echo 'need two parameters: $0 <interval> <pid>'
9 exit 1;
12 INTERVAL=$1
13 PID=$2
15 MAXMEM=0
16 NLINE=0
18 while [ $(ps -p $PID|wc -l) -gt 1 ];do
19 REPORT=`ps -o time,rss -p $PID | tail -1`
20 NLINE=`ps -o time,rss -p $PID | wc -l`
21 ARR=(${REPORT//\ +/ })
22 TEMP=${ARR[0]}
23 if [[ ${NLINE} -gt 1 ]];then
24 TIME=$TEMP
25 MEM=${ARR[1]}
26 if [ $MEM -gt $MAXMEM ];then
27 MAXMEM=$MEM
30 sleep $1
31 done
33 echo 'CPU time (mm:ss):' $TIME
34 echo 'Max mem (KB):' $MAXMEM