1#!/usr/bin/env bash 2 3# Script to do performance testing. 4 5# Invocation 6# check_performance SRC_DIR BUILD_DIR 7 8# 1: variables 9# 10SRC_DIR=$1 11BUILD_DIR=$2 12 13# Now that we've successfully translated the numerical option into 14# a symbolic one, we can safely ignore it. 15shift 16 17# This has been true all along. Found out about it the hard way... 18case $BASH_VERSION in 19 1*) 20 echo 'You need bash 2.x to run check_performance. Exiting.'; 21 exit 1 ;; 22 *) ;; 23esac 24 25flags_script=$BUILD_DIR/scripts/testsuite_flags 26INCLUDES=`$flags_script --build-includes` 27PCH_FLAGS=`$flags_script --cxxpchflags` 28FLAGS=`$flags_script --cxxflags` 29THREAD_FLAG='-pthread' 30COMPILER=`$flags_script --build-cxx` 31SH_FLAG="-Wl,--rpath -Wl,$BUILD_DIR/../../gcc \ 32 -Wl,--rpath -Wl,$BUILD_DIR/src/.libs" 33ST_FLAG="-static" 34LINK=$SH_FLAG 35CXX="$COMPILER $INCLUDES $FLAGS -std=gnu++0x $CXXFLAGS $LINK" 36LIBS="./libtestc++.a" 37TESTS_FILE="testsuite_files_performance" 38 39echo CXX is $CXX 40 41for NAME in `cat $TESTS_FILE` 42do 43 RUN=true 44 TESTNAME=$SRC_DIR/testsuite/$NAME 45 FILE_NAME="`basename $NAME`" 46 FILE_NAME="`echo $FILE_NAME | sed 's/.cc//g'`" 47 48 # TEST_S == single thread 49 # TEST_B == do both single and multi-thread 50 # TEST_T == multi-thread 51 for CYCLE in `sed -n 's,.*\(TEST_[SB][0-9]*\)$,\1,p' $TESTNAME` 52 do 53 RUN=false 54 echo $NAME $CYCLE 55 EXE_NAME="`echo $FILE_NAME-$CYCLE.exe`" 56 $CXX -DNOTHREAD -D$CYCLE $TESTNAME $LIBS -o $EXE_NAME 57 if [ -f $EXE_NAME ]; then 58 ./$EXE_NAME 59 else 60 echo "compile error:" 61 echo "$CXX -DNOTHREAD -D$CYCLE $TESTNAME $LIBS -o $EXE_NAME" 62 fi 63 done 64 65 for CYCLE in `sed -n 's,.*\(TEST_[TB][0-9]*\)$,\1,p' $TESTNAME` 66 do 67 RUN=false 68 echo $NAME $CYCLE thread 69 EXE_NAME="`echo $FILE_NAME-$CYCLE.exe`" 70 $CXX $THREAD_FLAG -D$CYCLE $TESTNAME $LIBS -o $EXE_NAME 71 if [ -f $EXE_NAME ]; then 72 ./$EXE_NAME 73 else 74 echo "compile error:" 75 echo "$CXX $THREAD_FLAG -D$CYCLE $TESTNAME $LIBS -o $EXE_NAME" 76 fi 77 done 78 79 if $RUN; then 80 echo $NAME 81 EXE_NAME="`echo $FILE_NAME.exe`" 82 $CXX $TESTNAME $LIBS -o $EXE_NAME 83 if [ -f $EXE_NAME ]; then 84 ./$EXE_NAME >& tmp.$FILE_NAME 85 else 86 echo "compile error:" 87 echo "$CXX $TESTNAME $LIBS -o $EXE_NAME" 88 fi 89 if [ -s tmp.$FILE_NAME ]; then 90 mv tmp.$FILE_NAME $FILE_NAME.xml 91 fi 92 fi 93done 94 95exit 0 96