| OLD | NEW |
| (Empty) |
| 1 #!/bin/bash --posix | |
| 2 # | |
| 3 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | |
| 4 # for details. All rights reserved. Use of this source code is governed by a | |
| 5 # BSD-style license that can be found in the LICENSE file. | |
| 6 | |
| 7 # Compiles the given benchmark and reports its size (zipped and unzipped). | |
| 8 # Removes 'out' directory if one exists. | |
| 9 | |
| 10 # Prevent problems where the caller has exported CLASSPATH, causing our | |
| 11 # computed value to be copied into the environment and double-counted | |
| 12 # against the argv limit. | |
| 13 unset CLASSPATH | |
| 14 | |
| 15 # Determine where the libs are | |
| 16 SCRIPT_DIR=`dirname $0` | |
| 17 DARTC_HOME=`cd $SCRIPT_DIR; pwd` | |
| 18 DIST_DIR=$DARTC_HOME/compiler | |
| 19 DARTC_LIBS=$DIST_DIR/lib | |
| 20 | |
| 21 OUT_DIR=out-size | |
| 22 DARTC_FLAGS="--optimize --out $OUT_DIR" | |
| 23 | |
| 24 # Make it easy to insert 'set -x' or similar commands when debugging problems wi
th this script. | |
| 25 eval "$JAVA_STUB_DEBUG" | |
| 26 | |
| 27 JVM_FLAGS=${JVM_FLAGS:-""} | |
| 28 JVM_FLAGS_CMDLINE="" | |
| 29 | |
| 30 while [ ! -z "$1" ]; do | |
| 31 case "$1" in | |
| 32 --debug) | |
| 33 JVM_DEBUG_PORT=${DEFAULT_JVM_DEBUG_PORT:-"5005"} | |
| 34 shift ;; | |
| 35 --debug=*) | |
| 36 JVM_DEBUG_PORT=${1/--debug=/} | |
| 37 shift ;; | |
| 38 --jvm_flags=*) | |
| 39 JVM_FLAGS_CMDLINE="$JVM_FLAGS_CMDLINE ${1/--jvm_flags=/}" | |
| 40 shift ;; | |
| 41 *) break ;; | |
| 42 esac | |
| 43 done | |
| 44 | |
| 45 if [ "$JVM_DEBUG_PORT" != "" ]; then | |
| 46 JVM_DEBUG_SUSPEND=${DEFAULT_JVM_DEBUG_SUSPEND:-"y"} | |
| 47 JVM_DEBUG_FLAGS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=${JVM_DEB
UG_SUSPEND},address=${JVM_DEBUG_PORT}" | |
| 48 fi | |
| 49 | |
| 50 # Delete existing out directory. | |
| 51 rm -rf $OUT_DIR | |
| 52 | |
| 53 mkdir $OUT_DIR | |
| 54 | |
| 55 # Big hack. We assume that the benchmark file is the last one in the list and | |
| 56 # lives in a directory called 'dart': | |
| 57 # x/y/dart/BenchmarkName.dart | |
| 58 # We remove everything (including other files) before the benchmark name, and | |
| 59 # then remove the extension. | |
| 60 BENCH_NAME=`echo $@ | sed 's/.*dart\///' | sed 's/.dart//'` | |
| 61 | |
| 62 APP_FILE=`readlink -f $1`; | |
| 63 APP_PATH=$(dirname $APP_FILE) | |
| 64 | |
| 65 $JAVABIN -classpath @CLASSPATH@ \ | |
| 66 ${JVM_DEBUG_FLAGS} \ | |
| 67 ${JVM_FLAGS} \ | |
| 68 ${JVM_FLAGS_CMDLINE} \ | |
| 69 com.google.dart.compiler.DartCompiler \ | |
| 70 $DARTC_FLAGS \ | |
| 71 "$APP_FILE" | |
| 72 | |
| 73 if [ ! "$? " = "0 " ]; then | |
| 74 echo "ERROR: Compilation failed." 1>&2 | |
| 75 exit 1 | |
| 76 fi | |
| 77 | |
| 78 OUT_FILE=`ls $OUT_DIR/file/$APP_PATH/*.opt.js` | |
| 79 | |
| 80 if [ ! "$? " = "0 " ]; then | |
| 81 echo "ERROR: couldn't find generated javascript file." 1>&2 | |
| 82 exit 3 | |
| 83 fi | |
| 84 | |
| 85 NB_APP_JS=`ls $OUT_DIR/file/$APP_PATH/*.opt.js | wc -l` | |
| 86 if [ "$NB_APP_JS" != "1" ]; then | |
| 87 echo "ERROR: more than one *.app.opt.js file." 1>&2 | |
| 88 exit 4 | |
| 89 fi | |
| 90 | |
| 91 echo "$BENCH_NAME-size: " `cat "$OUT_FILE" | wc -c` | |
| 92 echo "$BENCH_NAME-zip-size: " `cat "$OUT_FILE" | gzip | wc -c` | |
| OLD | NEW |