From c0a35285e53870b4f8f0be9857debc39e61f6ba2 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Tue, 19 Jul 2011 18:06:31 +0200 Subject: [PATCH] Add option to compress output files in run-all. --- Experimentations/run-all | 44 ++++++++++++++++++++++++++-------------- TODO | 1 - 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/Experimentations/run-all b/Experimentations/run-all index 6d556ec..9d43542 100755 --- a/Experimentations/run-all +++ b/Experimentations/run-all @@ -10,6 +10,7 @@ Options: -h print this help -n dry-run mode (for debugging) -c (continue) do not overwrite previous results + -z compress output files with gzip EOF exit $1 } @@ -34,11 +35,13 @@ array_check() { # read args overwrite=1 debug=0 -while getopts "chn" c; do +compress=0 +while getopts "chnz" c; do case "$c" in 'c') overwrite=0 ;; 'h') usage 0 ;; 'n') debug=1 ;; + 'z') compress=1 ;; '?') usage 1 ;; esac done @@ -80,11 +83,18 @@ outfile() { } summary() { - sed -n '\!^\[main/INFO\] ,----\[ Results \]!,${ - /send\|recv\|wall clock\|Simulation succeeded/d;p; - }' "$1" + gzip -cdf "$@" \ + | sed -n '\!^\[main/INFO\] ,----\[ Results \]!,${ + /send\|recv\|wall clock\|Simulation succeeded/d;p; + }' } +if [ $compress = 1 ]; then + outsuffix=".gz" +else + outsuffix="" +fi + for plat in "${PLATFORMS[@]}"; do tmp=$(basename "$plat" ".xml") plat_output="$RESULTS/plat_$tmp" @@ -104,24 +114,28 @@ for plat in "${PLATFORMS[@]}"; do for bk in "" "-b"; do tmp=$(outfile "loba" $bk "${args[@]}") out="$algo_output/$tmp.out" + outf="$out$outsuffix" cmd=( "$LOBA" "${COMMON_OPTS[@]}" $bk "${args[@]}" ) - log "Run: ${cmd[@]}"$'\n'"... &> $out" - if [ $overwrite = 0 -a -e "$out" ]; then + log "Run: ${cmd[@]}"$'\n'"... &> $outf" + if [ $overwrite = 0 -a -e "$outf" ]; then log "already run !" - summary "$out" + summary "$outf" continue fi if [ $debug = 1 ]; then log "skipped (dry-run)" + continue + fi + rm -f "$outf"; + echo "# ${cmd[@]}" > "$out" + if "${cmd[@]}" >> "$out" 2>&1; then + summary "$out" else - echo "# ${cmd[@]}" > "$out" - if "${cmd[@]}" >> "$out" 2>&1; then - summary "$out" - else - grep -v '/INFO\]' "$out" - fi -### FIXME : make this step optional -gzip --best "$out" + grep -v '/INFO\]' "$out" + fi + if [ $compress = 1 ]; then + log "Compress output file." + gzip --best "$out" fi done done diff --git a/TODO b/TODO index 329df78..fcd2d79 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,4 @@ * In run-all: - - Fix compression of output files (make it optional?). - Use more legible names for generated files. Current problems are: . file names are too long. -- 2.39.5