1 #!/bin/bash 2 # Copyright 2016 The Chromium OS 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 # 6 # Script for generating and running telemetry benchmarkes via crosperf with 7 # different perf command lines in order to measure the impact of the perf 8 # commands on performance. Crosperf cannot run the same benchmark multiple 9 # times, so this script runs crosperf multpilpe times instead. Unfortunately, 10 # this means you must compare the results yourself. 11 # 12 # Perf will run for the entire benchmark run, so results should be interpreted 13 # in that context. i.e, if this shows a 3% overhead for a particular perf 14 # command, that overhead would only be seen during the 2 seconds of measurement 15 # during a Chrome OS Wide Profiling collection. 16 set -e 17 18 board=xxx #<you-board-here> 19 remote=xxx #<your-remote-here> 20 iterations=5 21 chromeos_root=~/chromiumos 22 chrome_src=~/chromium 23 24 25 function GenerateExperiment() { 26 local perf_args="${1:+perf_args: $1}" 27 local track="$2" # stable, beta, dev 28 29 cat <<_EOF 30 $perf_args 31 benchmark: page_cycler_v2.typical_25 { 32 suite: telemetry_Crosperf 33 } 34 35 $track { 36 build: latest-$track 37 } 38 _EOF 39 } 40 41 function RunExperiment() { 42 local name="$1" 43 local perf_command="$2" 44 GenerateExperiment "$perf_command" "stable" > /tmp/crosperf.exp 45 ./crosperf /tmp/crosperf.exp \ 46 --name telemetry_perf_perf_${name} \ 47 --board="${board}" \ 48 --remote="${remote}" \ 49 --iterations="${iterations}" \ 50 --chromeos_root="${chromeos_root}" \ 51 --chrome_src="${chrome_src}" \ 52 --rerun=true \ 53 --use_file_locks=true \ 54 --locks_dir=/tmp/crosperf.locks 55 } 56 57 if [ "$board" = "xxx" -o "$remote" = "xxx" ]; then 58 echo "Please set board and remote at the top of this script before running." 59 exit -1 60 fi 61 62 63 # Note that "-a" is automatically inserted in the perf command line. 64 65 # Control: No profiling. 66 RunExperiment 'control' '' 67 # This is our baseline standard 'cycles' perf command. 68 RunExperiment 'cycles.flat' \ 69 'record -e cycles -c 1000003' 70 # Callgraph profiling. 71 RunExperiment 'cycles.callgraph' \ 72 'record -g -e cycles -c 4000037' 73 # Memory bandwidth profiling. As a perf stat command, we expect imperceptible 74 # overhead. 75 RunExperiment 'memory.bandwidth' \ 76 'stat -e cycles -e instructions -e uncore_imc/data_reads/ -e uncore_imc/data_writes/ -e cpu/event=0xD0,umask=0x11,name=MEM_UOPS_RETIRED-STLB_MISS_LOADS/ -e cpu/event=0xD0,umask=0x12,name=MEM_UOPS_RETIRED-STLB_MISS_STORES/' 77 78