v8/tools/profiling/linux-perf-chrome-renderer-cmd.sh
Camillo Bruni 7dd7100502 [tools][perf] Adding linux-perf d8 helper
- Start moving profiler scripts to tools/profiling
- Add linux-perf-d8.py wrapper script that runs `perf record` and
  `perf inject`
- Improve waiting for the d8/chrome process and allow for early
  termination if --timeout is provided
- Allow fractional seconds for --timeout
- Delete run-perf.sh and provide equivalent functionality in
  linux-perf-d8.py

Change-Id: Iac1d6cf895aa7159a9bbb387aca7632df27a0ca3
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3585951
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/main@{#79991}
2022-04-14 14:06:01 +00:00

46 lines
1.5 KiB
Bash
Executable File

#!/usr/bin/env bash
# Copyright 2022 the V8 project authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
PERF_DATA_DIR="."
PERF_DATA_PREFIX="chrome_renderer"
RENDERER_ID="0"
for i in "$@"; do
case $i in
--help)
echo "Usage: path/to/chrome --renderer-cmd-prefix='$0 [OPTION]' [CHROME OPTIONS]"
echo "This script is mostly used in conjuction with linux_perf.py to run linux-perf"
echo "for each renderer process."
echo "It generates perf.data files that can be read by pprof or linux-perf."
echo ""
echo 'File naming: ${OUT_DIR}/${PREFIX}_${PARENT_PID}_${RENDERER_ID}.perf.data'
echo ""
echo "Options:"
echo " --perf-data-dir=OUT_DIR Change the location where perf.data is written."
echo " Default: '$PERF_DATA_DIR'"
echo " --perf-data-prefix=PREFIX Set a custom prefex for all generated perf.data files."
echo " Default: '$PERF_DATA_PREFIX'"
exit
;;
--perf-data-dir=*)
PERF_DATA_DIR="${i#*=}"
shift
;;
--perf-data-prefix=*)
PERF_DATA_PREFIX="${i#*=}"
shift
;;
--renderer-client-id=*)
# Don't shift this option since it is passed in (and used by) chrome.
RENDERER_ID="${i#*=}"
;;
*)
;;
esac
done
PERF_OUTPUT="$PERF_DATA_DIR/${PERF_DATA_PREFIX}_${PPID}_${RENDERER_ID}.perf.data"
perf record --call-graph=fp --clockid=mono --freq=max --output="${PERF_OUTPUT}" -- $@