#!/bin/bash # Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. set -e OUTBRAIN_DIR='/outbrain' SPARK_DIR='/tmp/spark' usage() { cat </dev/null; then echo "Expected tfrecords (${tfrecords}) to be positive integer" usage exit 1 fi if ! [ "$iter" -ge 0 ] 2>/dev/null; then echo "Expected iteration (${iter}) to be positive integer" usage exit 1 fi function clean() { case "$1" in nvtabular) rm -rf "$OUTBRAIN_DIR/data" rm -rf "$OUTBRAIN_DIR/tfrecords" ;; spark) rm -rf "$SPARK_DIR" rm -rf "$OUTBRAIN_DIR/tfrecords" ;; esac } SECONDS=0 for i in $(seq 1 "$iter"); do echo "[BENCHMARK] Cleaning directories" clean "${mode}" echo "[BENCHMARK] Running iteration ${i}" bash scripts/memscript.sh & bash scripts/preproc.sh "${mode}" "${tfrecords}" echo "[BENCHMARK] Memory consumption during iteration ${i} (kB): $(cat mem_consumption.txt)" done echo -e "\n[BENCHMARK] Benchmark finished:\n" echo "[BENCHMARK] Memory consumption (kB): $(cat mem_consumption.txt)" rm mem_consumption.txt echo "[BENCHMARK] Mode=${mode}" echo "[BENCHMARK] Iteration=${iter}" echo "[BENCHMARK] Tfrecords=${tfrecords}" AVG_SECONDS=$((("$SECONDS" + "$iter" / 2) / "$iter")) printf '[BENCHMARK] Total time elapsed: %dh:%dm:%ds\n' $(("$SECONDS" / 3600)) $(("$SECONDS" % 3600 / 60)) $(("$SECONDS" % 60)) printf '[BENCHMARK] Average iteration time: %dh:%dm:%ds\n\n' $(("$AVG_SECONDS" / 3600)) $(("$AVG_SECONDS" % 3600 / 60)) $(("$AVG_SECONDS" % 60))