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. 18set -e 19 20JAVAC_SOURCE=1.7 21JAVAC_TARGET=1.8 22JAVAC_OPTIONS="-Xlint:-options -source ${JAVAC_SOURCE} -target ${JAVAC_TARGET}" 23 24# Write out classes 25 26${JAVAC} ${JAVAC_OPTIONS} ClassGen.java 27 28mkdir src 29mkdir classes 30 31# Heap size, min and max 32MEM=4g 33 34MULTIDEX="--multi-dex" 35THREADS="--num-threads=5" 36 37# Extra statistics, use to calibrate test. 38#EXTRA="--profile-concurrency" 39 40# Test smaller dex files 41#EXTRA="--set-max-idx-number=20000" 42 43# Test GC options 44#GC="-JXX:+UseConcMarkSweepGC" 45 46# Limit HW threads 47#TASKSET="taskset 0x00000fff 48 49# Number of classes, initial 50TEST_SIZE=1000 51 52# number of classes, max 53LIMIT=1000 54 55# Number of additional classes per test 56STEP=100 57 58# Number of fields per classes 59FIELDS=4 60 61# Number of methods per class 62METHODS=6 63 64first=1; 65while [ $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} ${JAVAC_OPTIONS} -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` 84done 85 86echo Yay! 87