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 # Write out classes 21 22 ${JAVAC} ClassGen.java 23 24 mkdir src 25 mkdir classes 26 27 # Heap size, min and max 28 MEM=4g 29 30 MULTIDEX="--multi-dex" 31 THREADS="--num-threads=5" 32 33 # Extra statistics, use to calibrate test. 34 #EXTRA="--profile-concurrency" 35 36 # Test smaller dex files 37 #EXTRA="--set-max-idx-number=20000" 38 39 # Test GC options 40 #GC="-JXX:+UseConcMarkSweepGC" 41 42 # Limit HW threads 43 #TASKSET="taskset 0x00000fff 44 45 # Number of classes, initial 46 TEST_SIZE=1000 47 48 # number of classes, max 49 LIMIT=1000 50 51 # Number of additional classes per test 52 STEP=100 53 54 # Number of fields per classes 55 FIELDS=4 56 57 # Number of methods per class 58 METHODS=6 59 60 61 first=1; 62 while [ $TEST_SIZE -le $LIMIT ]; do 63 rm -rf out 64 mkdir out 65 66 sleep 2 67 java -classpath . ClassGen $first $TEST_SIZE $FIELDS $METHODS 68 first=`expr $TEST_SIZE + 1` 69 70 ${JAVAC} -d classes `find src -name '*.java'` 71 (cd classes; jar cf ../x.jar `find . -name '*.class'`) 72 sleep 3 73 74 start=`date +'%s%N'` 75 $TASKSET dx -JXmx$MEM -JXms$MEM $GC --dex $EXTRA --no-optimize $MULTIDEX $THREADS --output=out x.jar 76 end=`date +'%s%N'` 77 nsec=`expr $end - $start` 78 msec=`expr $nsec / 1000000` 79 echo "Classes/msec $TEST_SIZE $msec" 80 81 TEST_SIZE=`expr $TEST_SIZE + $STEP` 82 done 83 84 if [ "$?" = "1" ]; then 85 echo "Yay!" 86 else 87 cat unit-out.txt 88 fi 89