-
-
Save redliu312/413c5b5ff6f772a7a5ee71e5f45af528 to your computer and use it in GitHub Desktop.
Revisions
-
netj revised this gist
Nov 30, 2015 . 1 changed file with 6 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -22,30 +22,30 @@ set -um # check input [[ $# -gt 0 ]] || { sed -n '2,/^#$/ s/^# //p' <"$0"; exit 1; } # TODO support more options: peak, footprint, sampling rate, etc. pgid=$(ps -o pgid= $$) # make sure we're in a separate process group if [[ "$pgid" == "$(ps -o pgid= $(ps -o ppid= $$))" ]]; then cmd= set -- "$0" "$@" for a; do cmd+="'${a//"'"/"'\\''"}' "; done exec bash -i -c "$cmd" fi # detect operating system and prepare measurement case $(uname) in Darwin|*BSD) sizes() { /bin/ps -o rss= -g $1; } ;; Linux) sizes() { /bin/ps -o rss= -$1; } ;; *) echo "$(uname): unsupported operating system" >&2; exit 2 ;; esac # monitor the memory usage in the background. ( peak=0 while sizes=$(sizes $pgid) do set -- $sizes sample=$((${@/#/+})) -
netj revised this gist
Nov 10, 2015 . 1 changed file with 16 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,6 +4,21 @@ # # Author: Jaeho Shin <[email protected]> # Created: 2010-08-16 ############################################################################ # Copyright 2010 Jaeho Shin. # # # # Licensed under the Apache License, Version 2.0 (the "License"); # # you may not use this file except in compliance with the License. # # You may obtain a copy of the License at # # # # http://www.apache.org/licenses/LICENSE-2.0 # # # # Unless required by applicable law or agreed to in writing, software # # distributed under the License is distributed on an "AS IS" BASIS, # # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # # See the License for the specific language governing permissions and # # limitations under the License. # ############################################################################ set -um # check input @@ -43,4 +58,4 @@ monpid=$! # run the given command exec "$@" -
netj revised this gist
Oct 31, 2011 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -13,7 +13,7 @@ set -um pgid=`ps -o pgid= $$` # make sure we're in a separate process group if [ $pgid = $(ps -o pgid= $(ps -o ppid= $$)) ]; then cmd= set -- "$0" "$@" for a; do cmd+="'${a//"'"/"'\\''"}' "; done -
netj revised this gist
Oct 31, 2011 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
Empty file. -
pcmdx revised this gist
Oct 19, 2011 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -13,7 +13,7 @@ set -um pgid=`ps -o pgid= $$` # make sure we're in a separate process group if [ $pgid = $(ps -o pgid= $(ps -o ppid= $$)) ]; then cmd= set -- "$0" "$@" for a; do cmd+="'${a//"'"/"'\\''"}' "; done -
netj revised this gist
Oct 15, 2010 . 1 changed file with 9 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,6 +11,15 @@ set -um # TODO support more options: peak, footprint, sampling rate, etc. pgid=`ps -o pgid= $$` # make sure we're in a separate process group if [ x$pgid = x$(ps -o pgid= $(ps -o ppid= $$)) ]; then cmd= set -- "$0" "$@" for a; do cmd+="'${a//"'"/"'\\''"}' "; done exec bash -i -c "$cmd" fi # detect operating system and prepare measurement case `uname` in Darwin|*BSD) sizes() { /bin/ps -o rss= -g $1; } ;; @@ -19,7 +28,6 @@ case `uname` in esac # monitor the memory usage in the background. ( peak=0 while sizes=`sizes $pgid` -
netj created this gist
Aug 16, 2010 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,38 @@ #!/usr/bin/env bash # memusg -- Measure memory usage of processes # Usage: memusg COMMAND [ARGS]... # # Author: Jaeho Shin <[email protected]> # Created: 2010-08-16 set -um # check input [ $# -gt 0 ] || { sed -n '2,/^#$/ s/^# //p' <"$0"; exit 1; } # TODO support more options: peak, footprint, sampling rate, etc. # detect operating system and prepare measurement case `uname` in Darwin|*BSD) sizes() { /bin/ps -o rss= -g $1; } ;; Linux) sizes() { /bin/ps -o rss= -$1; } ;; *) echo "`uname`: unsupported operating system" >&2; exit 2 ;; esac # monitor the memory usage in the background. pgid=`ps -o pgid= $$` ( peak=0 while sizes=`sizes $pgid` do set -- $sizes sample=$((${@/#/+})) let peak="sample > peak ? sample : peak" sleep 0.1 done echo "memusg: peak=$peak" >&2 ) & monpid=$! # run the given command exec "$@"