linux-perf-renderer-cmd.sh 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #!/bin/bash
  2. # Copyright 2022 The Chromium Authors. All rights reserved.
  3. # Use of this source code is governed by a BSD-style license that can be
  4. # found in the LICENSE file.
  5. PERF_DATA_DIR="."
  6. PERF_DATA_PREFIX="chrome_renderer"
  7. RENDERER_ID="0"
  8. PERF_RECORD_FREQ="max"
  9. for i in "$@"; do
  10. case $i in
  11. --help)
  12. cat <<EOM
  13. Usage: path/to/chrome --renderer-cmd-prefix='${0} [OPTION]' [CHROME OPTIONS]
  14. This script is used to run linux-perf for each renderer process.
  15. It generates perf.data files that can be read by pprof or linux-perf.
  16. Output: \$OUT_DIR/\$PREFIX_\$PPID_\$RENDERER_ID.perf.data
  17. Options:
  18. --perf-data-dir=OUT_DIR Change the location where perf.data is written.
  19. Default: '${PERF_DATA_DIR}'
  20. --perf-data-prefix=PREFIX Set a custom prefix for all generated perf.data
  21. files.
  22. Default: '${PERF_DATA_PREFIX}'
  23. --perf-freq=FREQ Sets the sampling frequency:
  24. 'perf record --freq=FREQ'
  25. Default: '${PERF_RECORD_FREQ}'
  26. EOM
  27. exit
  28. ;;
  29. --perf-data-dir=*)
  30. PERF_DATA_DIR="${i#*=}"
  31. shift
  32. ;;
  33. --perf-data-prefix=*)
  34. PERF_DATA_PREFIX="${i#*=}"
  35. shift
  36. ;;
  37. --perf-freq=*)
  38. PERF_RECORD_FREQ="${i#*=}"
  39. shift
  40. ;;
  41. --renderer-client-id=*)
  42. # Don't shift this option since it is passed in (and used by) chrome.
  43. RENDERER_ID="${i#*=}"
  44. ;;
  45. *)
  46. ;;
  47. esac
  48. done
  49. PERF_OUTPUT="$PERF_DATA_DIR/${PERF_DATA_PREFIX}_${PPID}_${RENDERER_ID}.perf.data"
  50. perf record \
  51. --call-graph=fp --clockid=mono --freq="${PERF_RECORD_FREQ}" \
  52. --output="${PERF_OUTPUT}" \
  53. -- $@