-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmprof.in
More file actions
executable file
·82 lines (67 loc) · 2.36 KB
/
mprof.in
File metadata and controls
executable file
·82 lines (67 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/sh
# Handle mprof options
if [ "${#}" -ne "0" ] ; then
case ${1} in
-h | --help)
# Print help
echo "This is the help of mprof"
echo " -v, --version Display the version"
echo " -h, --help Display this help"
echo " -l, --list Display the list of environment variable options"
echo " --options=... Allow users to put environment variable options directly in the command line. Note that you must *remove* hyphen --."
echo " --summary=PROCESS_ID Display the file that contain the summary of process PROCESS_ID"
exit 0
;;
-v | --version)
# Print version
echo "mprof (MPROF) 0.0.1"
echo "GNU General Public License v3.0"
exit 0
;;
-l | --list)
# Print list of environment variable options
echo "List of MPROF_OPTIONS options:"
echo " --verbose"
echo " --barrier"
echo " --init"
echo " --finalize"
echo " --profile"
exit 0
;;
--clean)
for suffix in summary out profile ; do
rm -Rf mprof_[0-9]*.${suffix}
done
exit 0
;;
--summary=*)
# Remove --summary=
process_id=${1#*=}
if [ "${process_id}" == "all" ] ; then
if [ -f mprof_0.summary ] ; then
cat mprof_*.summary
else
echo "Sorry, no summary file (need at least the summary of process 0 to invoke all)"
fi
else
file=mprof_${process_id}.summary
if [ -f ${file} ] ; then
cat ${file}
else
echo "Sorry, the summary of process ${process_id} is NOT availabe"
fi
fi
exit 0
;;
--options=*)
# Remove --options=
options=${1#*=}
# Run mprof
MPROF_OPTIONS="--$options" LD_PRELOAD="/usr/local/lib/libmprof.so" ${@:2}
;;
*)
# Run mprof
LD_PRELOAD="/usr/local/lib/libmprof.so" ${@}
;;
esac
fi