1 #!/bin/bash 2 # 3 # Copyright (C) 2013 The Android Open Source Project 4 # 5 # Licensed under the Apache License, Version 2.0 (the "License"); 6 # you may not use this file except in compliance with the License. 7 # You may obtain a copy of the License at 8 # 9 # http://www.apache.org/licenses/LICENSE-2.0 10 # 11 # Unless required by applicable law or agreed to in writing, software 12 # distributed under the License is distributed on an "AS IS" BASIS, 13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 # See the License for the specific language governing permissions and 15 # limitations under the License. 16 17 # Stop if something fails. 18 set -e 19 20 JAVAC_SOURCE=1.6 21 JAVAC_TARGET=1.6 22 23 # Write out classes 24 25 ${JAVAC} -source ${JAVAC_SOURCE} -target ${JAVAC_TARGET} ClassGen.java 26 27 mkdir src 28 mkdir classes 29 30 # Heap size, min and max 31 MEM=4g 32 33 MULTIDEX="--multi-dex" 34 THREADS="--num-threads=5" 35 36 # Extra statistics, use to calibrate test. 37 #EXTRA="--profile-concurrency" 38 39 # Test smaller dex files 40 #EXTRA="--set-max-idx-number=20000" 41 42 # Test GC options 43 #GC="-JXX:+UseConcMarkSweepGC" 44 45 # Limit HW threads 46 #TASKSET="taskset 0x00000fff 47 48 # Number of classes, initial 49 TEST_SIZE=1000 50 51 # number of classes, max 52 LIMIT=1000 53 54 # Number of additional classes per test 55 STEP=100 56 57 # Number of fields per classes 58 FIELDS=4 59 60 # Number of methods per class 61 METHODS=6 62 63 64 first=1; 65 while [ $TEST_SIZE -le $LIMIT ]; do 66 echo $TEST_SIZE / $LIMIT 67 rm -rf out 68 mkdir out 69 70 sleep 2 71 java -classpath . ClassGen $first $TEST_SIZE $FIELDS $METHODS || exit 1 72 first=`expr $TEST_SIZE + 1` 73 74 ${JAVAC} -source ${JAVAC_SOURCE} -target ${JAVAC_TARGET} -d classes `find src -name '*.java'` || exit 1 75 (cd classes; jar cf ../x.jar `find . -name '*.class'`) 76 sleep 3 77 78 start=`date +'%s%N'` 79 $TASKSET dx -JXmx$MEM -JXms$MEM $GC --dex $EXTRA --no-optimize $MULTIDEX $THREADS --output=out x.jar || exit 1 80 end=`date +'%s%N'` 81 nsec=`expr $end - $start` 82 msec=`expr $nsec / 1000000` 83 TEST_SIZE=`expr $TEST_SIZE + $STEP` 84 done 85 86 echo Yay! 87