diff options
author | csilvers <csilvers@6b5cf1ce-ec42-a296-1ba9-69fdba395a50> | 2007-04-16 20:49:32 +0000 |
---|---|---|
committer | csilvers <csilvers@6b5cf1ce-ec42-a296-1ba9-69fdba395a50> | 2007-04-16 20:49:32 +0000 |
commit | 74ad5d57ec08abace386befc6c3c695d85f44d1a (patch) | |
tree | 1a5611be12a74fde48de69d13476ab02ca7d20cc /src/tests/profiler_unittest.sh | |
parent | ddbf2f027fb4ca8781fd50820ceb870570f414bc (diff) | |
download | gperftools-74ad5d57ec08abace386befc6c3c695d85f44d1a.tar.gz |
Fri Apr 13 14:50:51 2007 Google Inc. <opensource@google.com>
* google-perftools: version 0.90 release
* (As the version-number jump hints, this is a major new release:
almost every piece of functionality was rewritten. I can't do
justice to all the changes, but will concentrate on highlights.)
*** USER-VISIBLE CHANGES:
* Ability to "release" unused memory added to tcmalloc
* Exposed more tweaking knobs via environment variables (see docs)
* pprof tries harder to map addresses to functions
* tcmalloc_minimal compiles and runs on FreeBSD 6.0 and Solaris 10
*** INTERNAL CHANGES:
* Much better 64-bit support
* Better multiple-processor support (e.g. multicore contention tweaks)
* Support for recent kernel ABI changes (e.g. new arg to mremap)
* Addition of spinlocks to tcmalloc to reduce contention cost
* Speed up tcmalloc by using __thread on systems that support TLS
* Total redesign of heap-checker to improve liveness checking
* More portable stack-frame analysis -- no more hard-coded constants!
* Disentangled heap-profiler code and heap-checker code
* Several new unittests to test, e.g., thread-contention costs
* Lots of small (but important!) bug fixes: e.g., fixing GetPC on amd64
*** KNOWN PROBLEMS:
* CPU-profiling may crash on x86_64 (64-bit) systems. See the README
* Profiling/heap-checking may deadlock on x86_64 systems. See README
git-svn-id: http://gperftools.googlecode.com/svn/trunk@28 6b5cf1ce-ec42-a296-1ba9-69fdba395a50
Diffstat (limited to 'src/tests/profiler_unittest.sh')
-rwxr-xr-x | src/tests/profiler_unittest.sh | 125 |
1 files changed, 67 insertions, 58 deletions
diff --git a/src/tests/profiler_unittest.sh b/src/tests/profiler_unittest.sh index cc6c52f..72d1c15 100755 --- a/src/tests/profiler_unittest.sh +++ b/src/tests/profiler_unittest.sh @@ -42,14 +42,19 @@ # This is because libtool sometimes turns the 'executable' into a # shell script which runs an actual binary somewhere else. -if [ -z "$2" ] -then - echo "USAGE: $0 <unittest dir> <pprof dir>" - exit 1 +# We expect BINDIR and PPROF_PATH to be set in the environment. +# If not, we set them to some reasonable values +BINDIR="${BINDIR:-.}" +PPROF_PATH="${PPROF_PATH:-$BINDIR/src/pprof}" + +if [ "x$1" = "x-h" -o "x$1" = "x--help" ]; then + echo "USAGE: $0 [unittest dir] [path to pprof]" + echo " By default, unittest_dir=$BINDIR, pprof_path=$PPROF_PATH" + exit 1 fi -UNITTEST_DIR=$1 -PPROF=$2/pprof +UNITTEST_DIR=${1:-$BINDIR} +PPROF=${2:-$PPROF_PATH} PROFILER1=$UNITTEST_DIR/profiler1_unittest PROFILER2=$UNITTEST_DIR/profiler2_unittest @@ -66,6 +71,10 @@ mkdir $TMPDIR || exit 2 num_failures=0 +RegisterFailure() { + num_failures=`expr $num_failures + 1` +} + # Takes two filenames representing profiles, with their executable scripts, # and a multiplier, and verifies that the 'contentful' functions in # each profile take the same time (possibly scaled by the given @@ -73,28 +82,28 @@ num_failures=0 # noise-reducing X units to each value. But even that would often # spuriously fail, so now it's "both non-zero". We're pretty forgiving. VerifySimilar() { - prof1=$TMPDIR/$1 - # We need to run the script with no args to get the actual exe name - exec1=`$2 2>&1 | awk '{print $2; exit;}'` - prof2=$TMPDIR/$3 - exec2=`$4 2>&1 | awk '{print $2; exit;}'` - mult=$5 - - mthread1=`$PPROF $exec1 $prof1 | grep test_main_thread | awk '{print $1}'` - mthread2=`$PPROF $exec2 $prof2 | grep test_main_thread | awk '{print $1}'` - mthread1_plus=`expr $mthread1 + 5` - mthread2_plus=`expr $mthread2 + 5` - if [ -z "$mthread1" ] || [ -z "$mthread2" ] || \ - [ "$mthread1" -le 0 -o "$mthread2" -le 0 ] + prof1=$TMPDIR/$1 + # We need to run the script with no args to get the actual exe name + exec1=`$2 2>&1 | awk '{print $2; exit;}'` + prof2=$TMPDIR/$3 + exec2=`$4 2>&1 | awk '{print $2; exit;}'` + mult=$5 + + mthread1=`$PPROF $exec1 $prof1 | grep test_main_thread | awk '{print $1}'` + mthread2=`$PPROF $exec2 $prof2 | grep test_main_thread | awk '{print $1}'` + mthread1_plus=`expr $mthread1 + 5` + mthread2_plus=`expr $mthread2 + 5` + if [ -z "$mthread1" ] || [ -z "$mthread2" ] || \ + [ "$mthread1" -le 0 -o "$mthread2" -le 0 ] # || [ `expr $mthread1_plus \* $mult` -gt `expr $mthread2_plus \* 2` -o \ # `expr $mthread1_plus \* $mult \* 2` -lt `expr $mthread2_plus` ] - then - echo - echo ">>> profile on $exec1 vs $exec2 with multiplier $mult failed:" - echo "Actual times (in profiling units) were '$mthread1' vs. '$mthread2'" - echo - num_failures=`expr $num_failures + 1` - fi + then + echo + echo ">>> profile on $exec1 vs $exec2 with multiplier $mult failed:" + echo "Actual times (in profiling units) were '$mthread1' vs. '$mthread2'" + echo + RegisterFailure + fi } # Takes a filenames representing a profile, with its executables, @@ -106,24 +115,24 @@ VerifySimilar() { # noise-reducing X units to each value. But even that would often # spuriously fail, so now it's "both non-zero". We're pretty forgiving. VerifyAcrossThreads() { - prof1=$TMPDIR/$1 - # We need to run the script with no args to get the actual exe name - exec1=`$2 2>&1 | awk '{print $2; exit;}'` - mult=$3 - - mthread=`$PPROF $exec1 $prof1 | grep test_main_thread | awk '{print $1}'` - othread=`$PPROF $exec2 $prof2 | grep test_other_thread | awk '{print $1}'` - if [ -z "$mthread" ] || [ -z "$othread" ] || \ - [ "$mthread" -le 0 -o "$othread" -le 0 ] + prof1=$TMPDIR/$1 + # We need to run the script with no args to get the actual exe name + exec1=`$2 2>&1 | awk '{print $2; exit;}'` + mult=$3 + + mthread=`$PPROF $exec1 $prof1 | grep test_main_thread | awk '{print $1}'` + othread=`$PPROF $exec2 $prof2 | grep test_other_thread | awk '{print $1}'` + if [ -z "$mthread" ] || [ -z "$othread" ] || \ + [ "$mthread" -le 0 -o "$othread" -le 0 ] # || [ `expr $mthread \* $mult \* 3` -gt `expr $othread \* 10` -o \ # `expr $mthread \* $mult \* 10` -lt `expr $othread \* 3` ] - then - echo - echo ">>> profile on $exec1 vs $exec2 with multiplier $mult failed:" - echo "Actual times (in profiling units) were '$mthread1' vs. '$mthread2'" - echo - num_failures=`expr $num_failures + 1` - fi + then + echo + echo ">>> profile on $exec1 vs $exec2 with multiplier $mult failed:" + echo "Actual times (in profiling units) were '$mthread1' vs. '$mthread2'" + echo + RegisterFailure + fi } echo @@ -134,47 +143,47 @@ echo "If the test does fail with an 'Actual times' error, try running again." echo # profiler1 is a non-threaded version -$PROFILER1 50 1 $TMPDIR/p1 -$PROFILER1 100 1 $TMPDIR/p2 +$PROFILER1 50 1 $TMPDIR/p1 || RegisterFailure +$PROFILER1 100 1 $TMPDIR/p2 || RegisterFailure VerifySimilar p1 $PROFILER1 p2 $PROFILER1 2 # Verify the same thing works if we statically link -$PROFILER2 50 1 $TMPDIR/p3 -$PROFILER2 100 1 $TMPDIR/p4 +$PROFILER2 50 1 $TMPDIR/p3 || RegisterFailure +$PROFILER2 100 1 $TMPDIR/p4 || RegisterFailure VerifySimilar p3 $PROFILER2 p4 $PROFILER2 2 # Verify the same thing works if we specify via CPUPROFILE -CPUPROFILE=$TMPDIR/p5 $PROFILER2 50 -CPUPROFILE=$TMPDIR/p6 $PROFILER2 100 +CPUPROFILE=$TMPDIR/p5 $PROFILER2 50 || RegisterFailure +CPUPROFILE=$TMPDIR/p6 $PROFILER2 100 || RegisterFailure VerifySimilar p5 $PROFILER2 p6 $PROFILER2 2 # When we compile with threads, things take a lot longer even when we only use 1 -CPUPROFILE=$TMPDIR/p5b $PROFILER3 10 -CPUPROFILE=$TMPDIR/p5c $PROFILER3 20 +CPUPROFILE=$TMPDIR/p5b $PROFILER3 10 || RegisterFailure +CPUPROFILE=$TMPDIR/p5c $PROFILER3 20 || RegisterFailure VerifySimilar p5b $PROFILER3 p5c $PROFILER3 2 # Now try what happens when we use threads -$PROFILER3 5 2 $TMPDIR/p7 -$PROFILER3 10 2 $TMPDIR/p8 +$PROFILER3 5 2 $TMPDIR/p7 || RegisterFailure +$PROFILER3 10 2 $TMPDIR/p8 || RegisterFailure VerifySimilar p7 $PROFILER3 p8 $PROFILER3 2 -$PROFILER4 5 2 $TMPDIR/p9 -$PROFILER4 10 2 $TMPDIR/p10 +$PROFILER4 5 2 $TMPDIR/p9 || RegisterFailure +$PROFILER4 10 2 $TMPDIR/p10 || RegisterFailure VerifySimilar p9 $PROFILER4 p10 $PROFILER4 2 # More threads! -$PROFILER4 2 3 $TMPDIR/p9 -$PROFILER4 4 3 $TMPDIR/p10 +$PROFILER4 2 3 $TMPDIR/p9 || RegisterFailure +$PROFILER4 4 3 $TMPDIR/p10 || RegisterFailure VerifySimilar p9 $PROFILER4 p10 $PROFILER4 2 # Compare how much time the main thread takes compared to the other threads # Recall the main thread runs twice as long as the other threads, by design. -$PROFILER4 2 4 $TMPDIR/p11 +$PROFILER4 2 4 $TMPDIR/p11 || RegisterFailure VerifyAcrossThreads p11 $PROFILER4 2 # Make sure that when we have a process with a fork, the profiles don't # clobber each other -CPUPROFILE=$TMPDIR/p6 $PROFILER1 1 -2 +CPUPROFILE=$TMPDIR/p6 $PROFILER1 1 -2 || RegisterFailure n=`ls $TMPDIR/p6* | wc -l` if [ $n != 3 ]; then echo "FORK test FAILED: expected 3 profiles (for main + 2 children), found $n" |