#!/usr/bin/env bash
#
# Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE file.
# Wrapper that runs a given Dart VM over the benchmarks with --verbose_gc
# and uses the verbose_gc_to_bmu script to produce a gallery of BMU graphs.
if test "$Argc" -ne 3
{
echo "Usage: $0 dart_binary benchmark_directory output_directory"
echo "Example: $0 out/ReleaseIA32/dart ../golem4/benchmarks /tmp/bmu"
exit 1
}
global DART_BIN := $1
global BENCH_DIR := $2
global OUT_DIR := $3
global VERBOSE_GC_TO_BMU := "$[dirname $0]/verbose_gc_to_bmu.dart"
global INDEX_FILE := "$OUT_DIR/index.html"
global TMP := '/tmp/bmu_benchmark_gallery'
mkdir -p $OUT_DIR
echo "
" > $INDEX_FILE
$DART_BIN --version !2 2>> $INDEX_FILE
echo "
" >> $INDEX_FILE
for NAME in [$[ls $BENCH_DIR]]
{
$DART_BIN --verbose_gc $BENCH_DIR/$NAME/dart/$NAME.dart !2 > $TMP.gclog &&
$DART_BIN $VERBOSE_GC_TO_BMU < $TMP.gclog > $TMP.dat &&
gnuplot -e "set term png; set output '$TMP.png'; set title '$NAME'; set ylabel 'BMU'; set xlabel 'Window size (ms)'; unset key; set yr [0:1]; set logscale x; plot '$TMP.dat' with linespoints" &&
mv -f $TMP.png $OUT_DIR/$NAME.png &&
mv -f $TMP.gclog $OUT_DIR/$NAME.txt &&
echo "
" >> $INDEX_FILE
}
echo "" >> $INDEX_FILE
(CommandList
children: [
(If
arms: [
(if_arm
cond: [(C {(Lit_Other "[")} {(DQ ($ VSub_Pound "$#"))} {(-ne)} {(3)} {(Lit_Other "]")})]
action: [
(C {(echo)}
{
(DQ ("Usage: ") ($ VSub_Number "$0")
(" dart_binary benchmark_directory output_directory")
)
}
)
(C {(echo)}
{
(DQ ("Example: ") ($ VSub_Number "$0")
(" out/ReleaseIA32/dart ../golem4/benchmarks /tmp/bmu")
)
}
)
(C {(exit)} {(1)})
]
spids: [-1 37]
)
]
spids: [-1 62]
)
(Assignment
keyword: Assign_None
pairs: [
(assign_pair
lhs: (LhsName name:DART_BIN)
op: Equal
rhs: {($ VSub_Number "$1")}
spids: [65]
)
]
spids: [65]
)
(Assignment
keyword: Assign_None
pairs: [
(assign_pair
lhs: (LhsName name:BENCH_DIR)
op: Equal
rhs: {($ VSub_Number "$2")}
spids: [68]
)
]
spids: [68]
)
(Assignment
keyword: Assign_None
pairs: [(assign_pair lhs:(LhsName name:OUT_DIR) op:Equal rhs:{($ VSub_Number "$3")} spids:[71])]
spids: [71]
)
(Assignment
keyword: Assign_None
pairs: [
(assign_pair
lhs: (LhsName name:VERBOSE_GC_TO_BMU)
op: Equal
rhs:
{
(CommandSubPart
command_list: (CommandList children:[(C {(dirname)} {(DQ ($ VSub_Number "$0"))})])
left_token:
spids: [76 82]
) (/verbose_gc_to_bmu.dart)
}
spids: [75]
)
]
spids: [75]
)
(Assignment
keyword: Assign_None
pairs: [
(assign_pair
lhs: (LhsName name:INDEX_FILE)
op: Equal
rhs: {($ VSub_Name "$OUT_DIR") (/index.html)}
spids: [85]
)
]
spids: [85]
)
(Assignment
keyword: Assign_None
pairs: [
(assign_pair
lhs: (LhsName name:TMP)
op: Equal
rhs: {(/tmp/bmu_benchmark_gallery)}
spids: [89]
)
]
spids: [89]
)
(C {(mkdir)} {(-p)} {($ VSub_Name "$OUT_DIR")})
(SimpleCommand
words: [{(echo)} {(DQ (""))}]
redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{($ VSub_Name "$INDEX_FILE")} spids:[105])]
)
(SimpleCommand
words: [{($ VSub_Name "$DART_BIN")} {(--version)}]
redirects: [(Redir op_id:Redir_DGreat fd:2 arg_word:{($ VSub_Name "$INDEX_FILE")} spids:[113])]
)
(SimpleCommand
words: [{(echo)} {(DQ ("
"))}]
redirects: [(Redir op_id:Redir_DGreat fd:-1 arg_word:{($ VSub_Name "$INDEX_FILE")} spids:[123])]
)
(ForEach
iter_name: NAME
iter_words: [
{
(CommandSubPart
command_list: (CommandList children:[(C {(ls)} {($ VSub_Name "$BENCH_DIR")})])
left_token:
spids: [133 137]
)
}
]
do_arg_iter: False
body:
(DoGroup
children: [
(AndOr
children: [
(SimpleCommand
words: [
{($ VSub_Name "$DART_BIN")}
{(--verbose_gc)}
{($ VSub_Name "$BENCH_DIR") (/) ($ VSub_Name "$NAME") (/dart/)
($ VSub_Name "$NAME") (.dart)
}
]
redirects: [
(Redir
op_id: Redir_Great
fd: 2
arg_word: {($ VSub_Name "$TMP") (.gclog)}
spids: [153]
)
]
)
(AndOr
children: [
(SimpleCommand
words: [{($ VSub_Name "$DART_BIN")} {($ VSub_Name "$VERBOSE_GC_TO_BMU")}]
redirects: [
(Redir
op_id: Redir_Less
fd: -1
arg_word: {($ VSub_Name "$TMP") (.gclog)}
spids: [165]
)
(Redir
op_id: Redir_Great
fd: -1
arg_word: {($ VSub_Name "$TMP") (.dat)}
spids: [170]
)
]
)
(AndOr
children: [
(C {(gnuplot)} {(-e)}
{
(DQ ("set term png; set output '") ($ VSub_Name "$TMP")
(".png'; set title '") ($ VSub_Name "$NAME")
(
"'; set ylabel 'BMU'; set xlabel 'Window size (ms)'; unset key; set yr [0:1]; set logscale x; plot '"
) ($ VSub_Name "$TMP") (".dat' with linespoints")
)
}
)
(AndOr
children: [
(C {(mv)} {(-f)} {($ VSub_Name "$TMP") (.png)}
{($ VSub_Name "$OUT_DIR") (/) ($ VSub_Name "$NAME") (.png)}
)
(AndOr
children: [
(C {(mv)} {(-f)} {($ VSub_Name "$TMP") (.gclog)}
{($ VSub_Name "$OUT_DIR") (/) ($ VSub_Name "$NAME") (.txt)}
)
(SimpleCommand
words: [
{(echo)}
{
(DQ ("
")
)
}
]
redirects: [
(Redir
op_id: Redir_DGreat
fd: -1
arg_word: {($ VSub_Name "$INDEX_FILE")}
spids: [235]
)
]
)
]
op_id: Op_DAmp
)
]
op_id: Op_DAmp
)
]
op_id: Op_DAmp
)
]
op_id: Op_DAmp
)
]
op_id: Op_DAmp
)
]
spids: [139 239]
)
spids: [132 -1]
)
(SimpleCommand
words: [{(echo)} {(DQ (""))}]
redirects: [(Redir op_id:Redir_DGreat fd:-1 arg_word:{($ VSub_Name "$INDEX_FILE")} spids:[247])]
)
]
)