| OLD | NEW |
| 1 #! /bin/sh | 1 #! /bin/sh |
| 2 # | 2 # |
| 3 # Copyright 2016 the V8 project authors. All rights reserved. | 3 # Copyright 2016 the V8 project authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 # | 6 # |
| 7 | 7 |
| 8 ########## Global variable definitions | 8 ########## Global variable definitions |
| 9 | 9 |
| 10 # Ensure that <your CPU clock> / $SAMPLE_EVERY_N_CYCLES < $MAXIMUM_SAMPLE_RATE. | 10 # Ensure that <your CPU clock> / $SAMPLE_EVERY_N_CYCLES < $MAXIMUM_SAMPLE_RATE. |
| 11 MAXIMUM_SAMPLE_RATE=10000000 | 11 MAXIMUM_SAMPLE_RATE=10000000 |
| 12 SAMPLE_EVERY_N_CYCLES=10000 | 12 SAMPLE_EVERY_N_CYCLES=10000 |
| 13 SAMPLE_RATE_CONFIG_FILE="/proc/sys/kernel/perf_event_max_sample_rate" | 13 SAMPLE_RATE_CONFIG_FILE="/proc/sys/kernel/perf_event_max_sample_rate" |
| 14 KERNEL_MAP_CONFIG_FILE="/proc/sys/kernel/kptr_restrict" | 14 KERNEL_MAP_CONFIG_FILE="/proc/sys/kernel/kptr_restrict" |
| 15 CALL_GRAPH_METHOD="fp" # dwarf does not play nice with JITted objects. | 15 CALL_GRAPH_METHOD="fp" # dwarf does not play nice with JITted objects. |
| 16 EVENT_TYPE=${EVENT_TYPE:=cycles:u} |
| 16 | 17 |
| 17 ########## Usage | 18 ########## Usage |
| 18 | 19 |
| 19 usage() { | 20 usage() { |
| 20 cat << EOF | 21 cat << EOF |
| 21 usage: $0 <benchmark_command> | 22 usage: $0 <benchmark_command> |
| 22 | 23 |
| 23 Executes <benchmark_command> under observation by Linux perf. | 24 Executes <benchmark_command> under observation by Linux perf. |
| 24 Sampling event is cycles in user space, call graphs are recorded. | 25 Sampling event is cycles in user space, call graphs are recorded. |
| 25 EOF | 26 EOF |
| (...skipping 13 matching lines...) Expand all Loading... |
| 39 fi | 40 fi |
| 40 | 41 |
| 41 ACTUAL_KERNEL_MAP_RESTRICTION=$(cat $KERNEL_MAP_CONFIG_FILE) | 42 ACTUAL_KERNEL_MAP_RESTRICTION=$(cat $KERNEL_MAP_CONFIG_FILE) |
| 42 if [ "$ACTUAL_KERNEL_MAP_RESTRICTION" -ne "0" ] ; then | 43 if [ "$ACTUAL_KERNEL_MAP_RESTRICTION" -ne "0" ] ; then |
| 43 echo "Disabling kernel address map restriction..." | 44 echo "Disabling kernel address map restriction..." |
| 44 echo 0 | sudo tee $KERNEL_MAP_CONFIG_FILE | 45 echo 0 | sudo tee $KERNEL_MAP_CONFIG_FILE |
| 45 fi | 46 fi |
| 46 | 47 |
| 47 echo "Running..." | 48 echo "Running..." |
| 48 perf record -R \ | 49 perf record -R \ |
| 49 -e cycles:u \ | 50 -e $EVENT_TYPE \ |
| 50 -c $SAMPLE_EVERY_N_CYCLES \ | 51 -c $SAMPLE_EVERY_N_CYCLES \ |
| 51 --call-graph $CALL_GRAPH_METHOD \ | 52 --call-graph $CALL_GRAPH_METHOD \ |
| 52 -i $@ --perf_basic_prof | 53 -i $@ --perf_basic_prof |
| OLD | NEW |