1#!/usr/bin/env bash 2# Copyright 2022 the V8 project 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 6PERF_DATA_DIR="." 7PERF_DATA_PREFIX="chrome_renderer" 8RENDERER_ID="0" 9for i in "$@"; do 10 case $i in 11 --help) 12 echo "Usage: path/to/chrome --renderer-cmd-prefix='$0 [OPTION]' [CHROME OPTIONS]" 13 echo "This script is mostly used in conjuction with linux_perf.py to run linux-perf" 14 echo "for each renderer process." 15 echo "It generates perf.data files that can be read by pprof or linux-perf." 16 echo "" 17 echo 'File naming: ${OUT_DIR}/${PREFIX}_${PARENT_PID}_${RENDERER_ID}.perf.data' 18 echo "" 19 echo "Options:" 20 echo " --perf-data-dir=OUT_DIR Change the location where perf.data is written." 21 echo " Default: '$PERF_DATA_DIR'" 22 echo " --perf-data-prefix=PREFIX Set a custom prefex for all generated perf.data files." 23 echo " Default: '$PERF_DATA_PREFIX'" 24 exit 25 ;; 26 --perf-data-dir=*) 27 PERF_DATA_DIR="${i#*=}" 28 shift 29 ;; 30 --perf-data-prefix=*) 31 PERF_DATA_PREFIX="${i#*=}" 32 shift 33 ;; 34 --renderer-client-id=*) 35 # Don't shift this option since it is passed in (and used by) chrome. 36 RENDERER_ID="${i#*=}" 37 ;; 38 *) 39 ;; 40 esac 41done 42 43 44PERF_OUTPUT="$PERF_DATA_DIR/${PERF_DATA_PREFIX}_${PPID}_${RENDERER_ID}.perf.data" 45perf record --call-graph=fp --clockid=mono --freq=max --output="${PERF_OUTPUT}" -- $@ 46