#!/bin/sh
. /usr/share/qa/qaset/libs/common.sh

NUMCPUS=`grep -c '^processor' /proc/cpuinfo`
NUMNODES=`grep ^Node /proc/zoneinfo | awk '{print $2}' | sort | uniq | wc -l`

# Performance test configuration with warmup
# Warmup phase eliminates cold-start effects before collecting statistics
# Interval reporting helps debugging but only final runtime value used for dashboard comparison
SCHBENCH_WARMUP=60       # 60 seconds warmup period
SCHBENCH_RUNTIME=120     # 120 seconds actual test runtime
SCHBENCH_INTERVAL=10     # Report every 10 seconds (for debugging)

SCHBENCH_MESSAGE_THREADS=$NUMNODES
SCHBENCH_THREADS=$(((NUMCPUS/NUMNODES)-1))


WORKLOAD_LOG_NAME=qa_test_schbench_warmup
WORKLOAD_NAME=process_scheduler_schbench_warmup
BENCHMARK_SCRIPT=/usr/bin/schbench
BENCHMARK_SCRIPT_OPTIONS="-r $SCHBENCH_RUNTIME -w $SCHBENCH_WARMUP -i $SCHBENCH_INTERVAL -m $SCHBENCH_MESSAGE_THREADS -t $SCHBENCH_THREADS"

sq_benchmark_run ${WORKLOAD_NAME} ${WORKLOAD_LOG_NAME} ${BENCHMARK_SCRIPT} ${BENCHMARK_SCRIPT_OPTIONS}

# Use WORKLOAD_RET_CODE in common.sh as exit code, which is the final return code of workload
[[ ${WORKLOAD_RET_CODE} -eq 0 ]] && exit 0 || exit 1
