File: perf-call-graph.sh

package info (click to toggle)
finalcut 0.9.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,832 kB
  • sloc: cpp: 90,264; makefile: 546; sh: 412
file content (49 lines) | stat: -rwxr-xr-x 1,006 bytes parent folder | download | duplicates (2)
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
#!/bin/bash

test -z "$EUID" && EUID=$(id -u)

if [ "$EUID" -ne 0 ]
then
  echo "You have to be root to run perf!"
  exit 1
fi

# Get number of logical processor cores
if command -v getconf >/dev/null 2>&1
then
  CPU_COUNT="$(getconf _NPROCESSORS_ONLN 2>/dev/null || getconf NPROCESSORS_ONLN 2>/dev/null)" || CPU_COUNT="0"
fi

if [ "$CPU_COUNT" -eq 0 ]
then
  if command -v nproc >/dev/null 2>&1
  then
    CPU_COUNT="$(nproc 2>/dev/null)" || CPU_COUNT="0"
  fi
fi

test "$CPU_COUNT" -eq 0 && CPU_COUNT=1

SAVE_DIR="$PWD"
cd .. || exit
make distclean
./configure --prefix="/usr" CXXFLAGS="-O3 -fno-omit-frame-pointer"
make -j$JOBS
cd "$SAVE_DIR"

echo 0 > /proc/sys/kernel/kptr_restrict

if [ $# -gt 0 ]
then
  LD_LIBRARY_PATH="../final/.libs/" perf record -g "$@"
else
  EXECUTABLE_FILE="../examples/.libs/ui"
  LD_LIBRARY_PATH="../final/.libs/" perf record -g "$EXECUTABLE_FILE"
fi

perf report -g 'graph,0.5,caller'
rm -f perf.data perf.data.old 2>/dev/null
cd .. || exit
make distclean
cd "$SAVE_DIR"