...
 
Commits (5)
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
click = "*"
[dev-packages]
[requires]
python_version = "2.7"
import click
import os
import subprocess as subp
@click.command()
@click.option("--build/--no-build", help="whether to build", default=True, show_default=True)
@click.option("--flags", "-f", help="flags to pass to DaCapo", default="")
@click.option("--verbose", "-v", help="show output from build and run", is_flag=True)
@click.argument("bench", type=click.Choice(['batik', 'eclipse', 'fop', 'h2', 'tomcat', 'tradebeans',
'luindex', 'sunflow', 'avrora', 'xalan', 'tradesoap',
'jython', 'lusearch','pmd', 'all']))
@click.argument("iterations", type=click.INT)
def main(build, flags, verbose, bench, iterations):
if build:
task = ("dist" if bench == 'all' else bench)
print "Building %s..." % task
subp.check_call(("ant %s" % task).split(), stdout=None if verbose else subp.PIPE)
dacapo_jar = filter(lambda s: s.startswith('dacapo') and s.endswith('.jar'), os.listdir('.'))[0]
benchmarks = subp.check_output(('java -jar %s -l' % dacapo_jar).split(' ')).strip().split()
total = { b: 0 for b in benchmarks }
first = {}
last = {}
for i in range(iterations):
print "Running iteration %d..." % i
for b in benchmarks:
print ("%s:" % b),
output = subp.check_output(("java -jar %s %s %s 2>&1 > /dev/null | grep \"PASSED\" | sed -E 's/.* in ([[:digit:]]+) msec .*/\\1/g'" % (dacapo_jar, b, flags)), shell=True)
msec = int(output)
print msec
total[b] += msec
if i == 0:
first[b] = msec
if i == iterations - 1:
last[b] = msec
for b in benchmarks:
avg = total[b] / iterations
print "---- Stats for %s ----" % b
print "Average: %d msec" % avg
print "First: %d msec" % first[b]
print "Last: %d msec" % last[b]
print "--------------------------"
if __name__ == "__main__":
main()
\ No newline at end of file
#!/bin/zsh
# NOTE: MUST USE BASH 4+, OTHERWISE USE ZSH
# BENCHMARK=$1
# SIZE=$2
# ITERATIONS=$3
# FLAGS=$4
function parse_args () {
POS=()
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
--no-build)
BUILD=false
shift # past argument
;;
*) # unknown option
POS+=("$1") # save it in an array for later
shift # past argument
;;
esac
done
BENCHMARK=$POS[1]
SIZE=$POS[2]
ITERATIONS=$POS[3]
FLAGS=$POS[4]
# set -- "${POS[@]}" # restore positional parameters
}
parse_args $*
if [ "$BENCHMARK" = "all" ]; then
BUILD_TASK="dist"
else
BUILD_TASK=$BENCHMARK
fi
# Building
if [ ! "$BUILD" = false ]; then
echo "Building $BUILD_TASK..."
ant $BUILD_TASK > /dev/null
fi
DACAPO_JAR=$(find . -maxdepth 1 -name '*.jar')
IFS=' ' BENCHMARKS=($(java -jar $DACAPO_JAR -l))
# Running
declare -A TOTAL
declare -A FIRST
declare -A LAST
for BENCH in $BENCHMARKS; do
TOTAL[$BENCH]=0
done
IFS=$'\n' ITER_IDX=($(seq 1 $ITERATIONS))
for ITER in $ITER_IDX; do
echo "Running iteration $ITER of size $SIZE..."
for BENCH in $BENCHMARKS; do
echo -n "$BENCH: "
MSEC=$(java -jar $DACAPO_JAR $BENCH -s $SIZE 2>&1 > /dev/null | grep "PASSED" | sed -E 's/.* in ([[:digit:]]+) msec .*/\1/g')
echo $MSEC
TOTAL[$BENCH]=$(expr $TOTAL[$BENCH] + $MSEC)
if [ $ITER -eq 1 ]; then
FIRST[$BENCH]=$MSEC
fi
if [ $ITER -eq $ITERATIONS ]; then
LAST[$BENCH]=$MSEC
fi
done
done
for BENCH in $BENCHMARKS; do
AVG=$(expr $TOTAL[$BENCH] / $ITERATIONS)
echo "---- Stats for $BENCH ----"
echo "Average: $AVG msec"
echo "First: $FIRST[$BENCH] msec"
echo "Last: $LAST[$BENCH] msec"
echo "--------------------------"
done
\ No newline at end of file