-#!/bin/bash
+#!/bin/bash -eu
# Copyright 2025 The OpenSSL Project Authors. All Rights Reserved.
#
# Licensed under the Apache License 2.0 (the "License").
BEGIN {RS = ""; FS = "\n"}
{file_num++; print > ("stacktrace" file_num ".txt")}' ./$LOGFILEBASE
popd > /dev/null
-rm $TEMPDIR/individual_files/$LOGFILEBASE
+rm -f $TEMPDIR/individual_files/$LOGFILEBASE
#
# Make some associative arrays to track our stats
echo "Gathering latencies"
FILECOUNT=$(ls $TEMPDIR/individual_files/stacktrace*.* | wc -l)
-let currentidx=0
+currentidx=0
#
# Look at every stack trace, get and record its latency, and hash value
#now compute its sha1sum
SHA1SUM=$(sha1sum $i | awk '{print $1}')
filenames["$SHA1SUM"]=$i
- let CUR_LATENCY=0
- let LATENCY_COUNT=0
+ CUR_LATENCY=0
+ LATENCY_COUNT=0
#
# If we already have a latency total for this hash value
#
if [[ -v total_latency["$SHA1SUM"] ]]
then
- let CUR_LATENCY=${total_latency["$SHA1SUM"]}
- let LATENCY_COUNT=${latency_counts["$SHA1SUM"]}
+ CUR_LATENCY=${total_latency["$SHA1SUM"]}
+ LATENCY_COUNT=${latency_counts["$SHA1SUM"]}
fi
#
total_latency["$SHA1SUM"]=$(dc -e "$CUR_LATENCY $LATENCY + p")
latency_counts["$SHA1SUM"]=$(dc -e "$LATENCY_COUNT 1 + p")
echo -e -n "FILE $currentidx/$FILECOUNT \r"
- let currentidx=$currentidx+1
+ currentidx=$((currentidx + 1))
done
#