Files
weave-scope/extras/dialer/time-scope-probe
Michael Schubert 4d20a91a97 Add extras/dialer
Based on the dialer.sh script by @alban:
https://gist.github.com/alban/7abe7f6307184c58be7429e63a2d9053

Signed-off-by: Michael Schubert <michael@kinvolk.io>
2016-12-13 09:31:57 +01:00

34 lines
740 B
Bash
Executable File

#!/bin/bash
set -eu
if [ $EUID -ne 0 ]; then
echo "You must be root!" >&2
exit 1
fi
readonly interval_num=${1:-60}
readonly interval_sleep=${2:-10}
TIME_U1=0
TIME_K1=0
TIME_T1=0
TIME_U2=0
TIME_K2=0
TIME_T2=0
if [ "$(pidof scope-probe)" == "" ]; then
echo "No scope-probe process running - aborting" >&2
exit 1
fi
for ((i=0; i<"$interval_num"; i++)); do
sleep "$interval_sleep"
TIME_U1=$TIME_U2
TIME_K1=$TIME_K2
TIME_T1=$TIME_T2
TIME_U2=$(gawk '{print $14"*10"}'<"/proc/$(pidof scope-probe)/stat" | bc)
TIME_K2=$(gawk '{print $15"*10"}'<"/proc/$(pidof scope-probe)/stat" | bc)
TIME_T2=$(( TIME_U2 + TIME_K2 ))
echo "utime $(( TIME_U2 - TIME_U1)) + stime $(( TIME_K2 - TIME_K1 )) = $(( TIME_T2 - TIME_T1 ))"
done