~nskaggs/+junk/xenial-test

« back to all changes in this revision

Viewing changes to src/github.com/lxc/lxd/test/suites/profiling.sh

  • Committer: Nicholas Skaggs
  • Date: 2016-10-24 20:56:05 UTC
  • Revision ID: nicholas.skaggs@canonical.com-20161024205605-z8lta0uvuhtxwzwl
Initi with beta15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
 
 
3
test_cpu_profiling() {
 
4
  LXD3_DIR=$(mktemp -d -p "${TEST_DIR}" XXX)
 
5
  chmod +x "${LXD3_DIR}"
 
6
  spawn_lxd "${LXD3_DIR}" --cpuprofile "${LXD3_DIR}/cpu.out"
 
7
  lxdpid=$(cat "${LXD3_DIR}/lxd.pid")
 
8
  kill -TERM "${lxdpid}"
 
9
  wait "${lxdpid}" || true
 
10
  export PPROF_TMPDIR="${TEST_DIR}/pprof"
 
11
  echo top5 | go tool pprof "$(which lxd)" "${LXD3_DIR}/cpu.out"
 
12
  echo ""
 
13
 
 
14
  kill_lxd "${LXD3_DIR}"
 
15
}
 
16
 
 
17
test_mem_profiling() {
 
18
  LXD4_DIR=$(mktemp -d -p "${TEST_DIR}" XXX)
 
19
  chmod +x "${LXD4_DIR}"
 
20
  spawn_lxd "${LXD4_DIR}" --memprofile "${LXD4_DIR}/mem"
 
21
  lxdpid=$(cat "${LXD4_DIR}/lxd.pid")
 
22
 
 
23
  if [ -e "${LXD4_DIR}/mem" ]; then
 
24
    false
 
25
  fi
 
26
 
 
27
  kill -USR1 "${lxdpid}"
 
28
 
 
29
  timeout=50
 
30
  while [ "${timeout}" != "0" ]; do
 
31
    [ -e "${LXD4_DIR}/mem" ] && break
 
32
    sleep 0.1
 
33
    timeout=$((timeout-1))
 
34
  done
 
35
 
 
36
  export PPROF_TMPDIR="${TEST_DIR}/pprof"
 
37
  echo top5 | go tool pprof "$(which lxd)" "${LXD4_DIR}/mem"
 
38
  echo ""
 
39
 
 
40
  kill_lxd "${LXD4_DIR}"
 
41
}