From d51d0aa5d5eca5f63da2b516c254dd1e87aa8703 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Tue, 27 Jan 2015 19:01:16 -0800 Subject: [PATCH] Add linker flag and test script for google-perftools --- script/util/run_tests.sh | 14 +++++++++++++- tests.gyp | 3 ++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/script/util/run_tests.sh b/script/util/run_tests.sh index 736c134f..4e3759e4 100644 --- a/script/util/run_tests.sh +++ b/script/util/run_tests.sh @@ -20,13 +20,14 @@ EOF } function run_tests { + local profile= local mode=normal local args=() local target=$1 local cmd="out/Debug/${target}" shift - while getopts "df:ghv" option; do + while getopts "df:ghpv" option; do case ${option} in h) usage @@ -38,6 +39,9 @@ function run_tests { g) mode=valgrind ;; + p) + profile=true + ;; f) args+=("--only=${OPTARG}") ;; @@ -50,6 +54,10 @@ function run_tests { BUILDTYPE=Debug make $target args=${args:-""} + if [[ -n $profile ]]; then + export CPUPROFILE=/tmp/${target}-$(date '+%s').prof + fi + case ${mode} in valgrind) valgrind \ @@ -74,4 +82,8 @@ function run_tests { time $cmd "${args[@]}" ;; esac + + if [[ -n $profile ]]; then + pprof $cmd $CPUPROFILE + fi } diff --git a/tests.gyp b/tests.gyp index 00915d1f..bb78a38e 100644 --- a/tests.gyp +++ b/tests.gyp @@ -65,6 +65,8 @@ '-std=c++0x', ], + 'libraries': ['-weak-lprofiler'], + 'xcode_settings': { 'CLANG_CXX_LANGUAGE_STANDARD': 'c++11', 'ALWAYS_SEARCH_USER_PATHS': 'NO', @@ -76,4 +78,3 @@ }, } } -