Skip to content

Commit b47ae24

Browse files
committed
shellcheck: remove shadowed duplicate helpers in lib_performance
Remove earlier duplicate definitions of perf_is_number, perf_run_cmd_tee, and perf_sysbench_csv_append from Runner/utils/lib_performance.sh. These earlier copies were shadowed by later definitions in the same file, so this cleanup does not change runtime behavior after the library is sourced. The change only removes dead duplicate code and addresses newer ShellCheck SC2317 warnings. Signed-off-by: Srikanth Muppandam <smuppand@qti.qualcomm.com>
1 parent e2005a1 commit b47ae24

1 file changed

Lines changed: 0 additions & 98 deletions

File tree

Runner/utils/lib_performance.sh

Lines changed: 0 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -864,16 +864,6 @@ perf_kpi_check_previous_reboot() {
864864
perf_kpi_reboot_state_save "$state_file" "$PERF_KPI_BOOT_ID" "$PERF_KPI_UPTIME_SEC" "0" "$PERF_KPI_STATE_ITER_DONE"
865865
}
866866

867-
# ---------------------------------------------------------------------------
868-
# Small math / parsing helpers (POSIX)
869-
# ---------------------------------------------------------------------------
870-
perf_is_number() {
871-
printf '%s\n' "$1" | awk '
872-
BEGIN{ok=0}
873-
/^[0-9]+(\.[0-9]+)?$/ {ok=1}
874-
END{exit(ok?0:1)}'
875-
}
876-
877867
perf_avg_file() {
878868
f=$1
879869
[ -s "$f" ] || { echo ""; return 0; }
@@ -987,56 +977,6 @@ perf_baseline_get() {
987977
# ---------------------------------------------------------------------------
988978
# Sysbench helpers (run + parse + average + optional CSV)
989979
# ---------------------------------------------------------------------------
990-
991-
# Run a command and stream output to console while also writing to a logfile.
992-
# POSIX-safe: uses mkfifo + tee to preserve command exit code.
993-
# Usage: perf_run_cmd_tee /path/to/log -- cmd args...
994-
perf_run_cmd_tee() {
995-
log_file=$1
996-
shift
997-
998-
[ -n "$log_file" ] || return 1
999-
1000-
dir=$(dirname "$log_file")
1001-
mkdir -p "$dir" 2>/dev/null || true
1002-
1003-
fifo="${log_file}.fifo.$$"
1004-
rm -f "$fifo" 2>/dev/null || true
1005-
1006-
if ! mkfifo "$fifo" 2>/dev/null; then
1007-
# Fallback: no fifo support → just log (no live console)
1008-
"$@" >"$log_file" 2>&1
1009-
return $?
1010-
fi
1011-
1012-
# Start tee first (reader)
1013-
tee "$log_file" <"$fifo" &
1014-
tee_pid=$!
1015-
1016-
# Run command, write both stdout+stderr into FIFO (writer)
1017-
"$@" >"$fifo" 2>&1
1018-
rc=$?
1019-
1020-
# Give tee a short window to drain+exit; then kill if still alive (avoid hangs)
1021-
i=0
1022-
while kill -0 "$tee_pid" 2>/dev/null; do
1023-
i=$((i + 1))
1024-
[ "$i" -ge 5 ] && break
1025-
sleep 1
1026-
done
1027-
1028-
if kill -0 "$tee_pid" 2>/dev/null; then
1029-
# tee is still alive unexpectedly → terminate and move on
1030-
kill "$tee_pid" 2>/dev/null || true
1031-
wait "$tee_pid" 2>/dev/null || true
1032-
else
1033-
wait "$tee_pid" 2>/dev/null || true
1034-
fi
1035-
1036-
rm -f "$fifo" 2>/dev/null || true
1037-
return $rc
1038-
}
1039-
1040980
# Parse total time (sec) from sysbench 1.0+ output.
1041981
# Supports both:
1042982
# "total time: 30.0009s"
@@ -1092,44 +1032,6 @@ perf_values_avg() {
10921032
' "$values_file" 2>/dev/null
10931033
}
10941034

1095-
# Optional CSV append (only if CSV_FILE is non-empty).
1096-
# CSV format:
1097-
# timestamp,test,threads,metric,iteration,value
1098-
perf_sysbench_csv_append() {
1099-
csv=$1
1100-
test=$2
1101-
threads=$3
1102-
metric=$4
1103-
iteration=$5
1104-
value=$6
1105-
status=${7:-}
1106-
baseline=${8:-}
1107-
goal=${9:-}
1108-
op=${10:-}
1109-
score_pct=${11:-}
1110-
delta=${12:-}
1111-
1112-
[ -n "$csv" ] || return 0
1113-
[ -n "$value" ] || return 0
1114-
1115-
dir=$(dirname "$csv")
1116-
mkdir -p "$dir" 2>/dev/null || true
1117-
1118-
if [ ! -f "$csv" ] || [ ! -s "$csv" ]; then
1119-
# Backward-compatible: old columns first, new columns appended.
1120-
echo "timestamp,test,threads,metric,iteration,value,status,baseline,goal,op,score_pct,delta" >"$csv"
1121-
fi
1122-
1123-
if command -v nowstamp >/dev/null 2>&1; then
1124-
ts=$(nowstamp)
1125-
else
1126-
ts=$(date "+%Y-%m-%d %H:%M:%S" 2>/dev/null || echo "unknown")
1127-
fi
1128-
1129-
# Always write all columns; empty fields are OK.
1130-
echo "$ts,$test,$threads,$metric,$iteration,$value,$status,$baseline,$goal,$op,$score_pct,$delta" >>"$csv" 2>/dev/null || true
1131-
}
1132-
11331035
# ---------------------------------------------------------------------------
11341036
# Sysbench helpers
11351037
# ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)