-
Notifications
You must be signed in to change notification settings - Fork 2
/
get_vmlatency.sh
executable file
·63 lines (49 loc) · 1.13 KB
/
get_vmlatency.sh
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
#!/bin/sh
SUDO=""
if [ ! -z `id -u` ]; then
SUDO="sudo"
fi
if [[ "$OSTYPE" == "linux-gnu" ]]; then
VMLATENCY=vmlatency.ko
CPU_NAME=`cat /proc/cpuinfo |grep "model name" |uniq |sed s/"^.*: "//`
function getlog {
dmesg
}
function build {
make clean
make
}
function load {
$SUDO /sbin/insmod $VMLATENCY
}
function unload {
$SUDO /sbin/rmmod $VMLATENCY
}
elif [[ "$OSTYPE" == "darwin"* ]]; then
VMLATENCY=build/Release/vmlatency.kext
CPU_NAME=`sysctl -n machdep.cpu.brand_string`
function getlog {
$SUDO dmesg
}
function build {
xcodebuild
}
function load {
$SUDO cp -r $1 /tmp/
$SUDO kextload /tmp/vmlatency.kext
}
function unload {
$SUDO kextunload /tmp/vmlatency.kext
}
else
echo "Unsupported OSTYPE $OSTYPE"
exit 1
fi
build
[ -e $VMLATENCY ] || { echo "$VMLATENCY does not exist" ; exit 1 ; }
for i in $(seq 1 20)
do
load $VMLATENCY
unload $VMLATENCY
done
getlog | grep "\[vmlatency\]" | sed s/^"\[ *"[0-9]*\.[0-9]*"\] "// |sed s/"\[vmlatency\] "// > "$CPU_NAME".txt