From e5561b873543324cb8f07ae9f291c285afa7f375 Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Mallo Date: Mon, 8 Feb 2021 14:14:08 +0100 Subject: [PATCH] control: save total execution time --- garlic/pp/timetable.nix | 5 ++++- garlic/sh/garlic | 2 ++ garlic/stages/control.nix | 15 +++++++++------ 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/garlic/pp/timetable.nix b/garlic/pp/timetable.nix index 3bed915..811e5ce 100644 --- a/garlic/pp/timetable.nix +++ b/garlic/pp/timetable.nix @@ -25,7 +25,10 @@ stdenv.mkDerivation { echo "check stdout log file: ${inputResult}/$exp/$unit/$run/stdout.log" exit 1 fi - jq -cn "{ exp:\"$exp\", unit:\"$unit\", config:inputs, time:$time, run:$run }" $conf >> $out + start_time=$(cat $run/.garlic/total_time_start) + end_time=$(cat $run/.garlic/total_time_end) + total_time=$(($end_time - $start_time)) + jq -cn "{ exp:\"$exp\", unit:\"$unit\", config:inputs, time:$time, run:$run, total_time:$total_time }" $conf >> $out done done done diff --git a/garlic/sh/garlic b/garlic/sh/garlic index 9da6520..765e875 100755 --- a/garlic/sh/garlic +++ b/garlic/sh/garlic @@ -136,6 +136,8 @@ do_fetch() { --include='*/*/garlic_config.json' \ --include='*/*/std*.log' \ --include='*/*/*/std*.log' \ + --include='*/*/*/.garlic' \ + --include='*/*/*/.garlic/*' \ --exclude='*/*/*/*' \ $exp $garlicTemp diff --git a/garlic/stages/control.nix b/garlic/stages/control.nix index 7e24b92..123c560 100644 --- a/garlic/stages/control.nix +++ b/garlic/stages/control.nix @@ -16,14 +16,17 @@ stdenv.mkDerivation { phases = [ "installPhase" ]; dontPatchShebangs = true; installPhase = '' - cat > $out < $out <<"EOF" #!/bin/sh -e - for n in \$(seq 1 ${toString loops}); do - export GARLIC_RUN="\$n" - echo "running \$n of ${toString loops}" > status - mkdir "\$n" - cd "\$n" + for n in $(seq 1 ${toString loops}); do + export GARLIC_RUN="$n" + echo "running $n of ${toString loops}" > status + mkdir "$n" + cd "$n" + mkdir .garlic + date +%s > .garlic/total_time_start ${stageProgram nextStage} + date +%s > .garlic/total_time_end cd .. done echo "completed" > status