theLink 10.0
Loading...
Searching...
No Matches
results.bash

Collect and present the performance test results as table.

usage
usage: results.bash ?options...? 
  options:
      -x|-v                # set bash debug flag            : debugging
      -debug               # be verbose                     : debugging
      -target              # select the target              : default NHI1_target
      -pr                  # select perf-release            : default both
      -pa                  # select perf-aggressive         : default both
      -h|--help            # get this message               : help

  Collect and present the performance test results as table:
    installation directory : WORK_DIR_BUILD/inst/TARGET/SETUP
    build directory        : NHI1_BUILD/TARGET/SETUP
    setup(s)               : perf-release perf-aggressive
    target(s)              : x86_64-suse-linux-gnu

code
#!/bin/bash
#+
#:   @file         NHI1/performance/results.bash
#:   @brief        tag: nhi1-release-250425
#:   @copyright    (C) NHI - #1 - Project - Group
#:                 This software has NO permission to copy,
#:                 please contact AUTHOR for additional information
#:

# find top-level directory
Nhi1Env -silent || exit 1

set -u

# shellcheck source=./libperf.bash
source "$NHI1_HOME/performance/libperf.bash"

function usage  {
  if (( $# )) ; then exec 1>&2 ; echo "ERROR: $*" ; fi

  usage_default.tcl "$cmd0"
  cat <<EOF

  Collect and present the performance test results as table:
    installation directory : WORK_DIR_BUILD/$perfdir/TARGET/SETUP
    build directory        : NHI1_BUILD/TARGET/SETUP
    setup(s)               : $(setupList)
    target(s)              : $(targetList)

EOF
  
  (( $# )) && exit 1 || exit 0
}

target="$NHI1_target"

setupL=(perf-release perf-aggressive)

while (( $# > 0 )) ; do 
  case "$1" in
    -x|-v)      # set bash debug flag     : debugging
                set "$1"                        ;;
    -debug)     # be verbose              : debugging
                debugI=1                        ;;
    -target)    # select the target       : default NHI1_target
                shift ; target="$2"             ;;
    -pr)        # select perf-release     : default both
                setupL=(perf-release)           ;;
    -pa)        # select perf-aggressive  : default both
                setupL=(perf-aggressive)        ;;
    -h|--help)  # get this message      : help
                usage                           ;;
    *)	        usage "invalid argument '$1'"   ;;
  esac
  shift
done

## setup the TOTAL - LINK perf
FSL=" %-25s | %-8s %-8s %-8s %-8s %-8s %-8s %-8s %-8s\n"
FIL=" %-25s | %8s %8s %8s %8s %8s %8s %8s %8s \n"
exec 3>"$WORK_DIR/gen/total_link.perf"
DATE=$(date +"%Y-%m-%d %H:%M:%S")

function header
{
echo -e '\n' 1>&3
# shellcheck disable=SC2059
printf "$FSL" "$target"                 "  send  " "  send  " "  send  " "  send  " " create  " " create " "  data  " "  data  "  1>&3
# shellcheck disable=SC2059
printf "$FSL" "$DATE"                   " NOTHING" "  END   " "CALLBACK" "  WAIT  " " PARENT  " " CHILD  " "  BUS   " "  BFL   "  1>&3
# shellcheck disable=SC2059
printf "$FSL" -------------------------  --------   --------   --------   --------   ---------   --------   --------   --------   1>&3
} 

# shellcheck disable=SC2034
c=C
# shellcheck disable=SC2034
cc=C++
# shellcheck disable=SC2034
cs=C#
# shellcheck disable=SC2034
jv=Java
# shellcheck disable=SC2034
pl=Perl
# shellcheck disable=SC2034
py=Python
# shellcheck disable=SC2034
rb=Ruby
# shellcheck disable=SC2034
tcl=Tcl
# shellcheck disable=SC2034
atl=ATL
# shellcheck disable=SC2034
vb=VB.NET
# shellcheck disable=SC2034
php=PHP
# shellcheck disable=SC2034
go=Go

TotalLink() {
  local perf=${1}_${2}
  local setup=$3;
  local -a valL VL
  IDX=0
  if [ "$setup" = "perf-release" ] ; then
    ID="R: ${!1}"
  else
    ID="A: ${!1}"
  fi
  perfFile="$result_root_dir/$setup/$perf.perf"
  if [[ -f "$perfFile" ]] ; then
    args_split_by valL $'\n' "$(awk -F ": " '/statistics/ {sub(/^  */, "", $3); printf("%d\n",$3)}' "$perfFile")"
    if (( "${#valL[@]}" != 8 )) ; then
      error $"expect 8 values to display but get '${#valL[@]}' !! \n  file=$perfFile'\n$(sed -e 's/^/    | /' $perfFile)"
    else
      # shellcheck disable=SC2059
      printf "$FIL" "$ID" "${valL[@]}" 1>&3
    fi
  else 
    # shellcheck disable=SC2059
    : printf "$FIL" "$ID" na. na. na. na. na. na. na. na. 1>&3
  fi
}

TotalBrain() {
  local perf=${1}_${2}
  local -a lineL
  IDX=0
  if test -f "$WORK_DIR/gen/$perf.perf" ; then
    FLAG=NO
    mapfile lineL < "$WORK_DIR/gen/$perf.perf"
    for LINE in "${lineL[@]}" ; do
      unset IFS
      [[ $LINE == *statistics* && $FLAG == "NO" ]] && {
        # shellcheck disable=SC2086
	set - ${LINE:68}
	N="$1 $2"
	V1="$5"
	FLAG=YES
	continue
      }
      [[ "$LINE" == *statistics* && "$FLAG" == "YES" ]] && {
        # shellcheck disable=SC2086
	set - ${LINE:68}
	[[ $N != "$1 $2" ]] && error FORMAT
	V2="$5"
	FLAG=NO

        # shellcheck disable=SC2059
	printf "$FIL" "   $N" "$V1" "$V2" 1>&4
	continue
      }
    done

  fi
}

# calculate the total
#for TST in pipe tcp_fork tcp_thread tcp_spawn uds_fork uds_thread uds_spawn; do
for TST in pipe uds_fork uds_thread uds_spawn; do
  header
  echo -e "\n $TST:" 1>&3
  #for LNG in c cc cs jv go pl py rb tcl php; do
  for setup in "${setupL[@]}"; do
    echo "" 1>&3
    for LNG in c cc py tcl atl jv rb cs ; do
      TotalLink "$LNG" "$TST" "$setup"
    done
  done
#  echo -e "\n $TST:" 1>&4
#  for LNG in brain; do
#    TotalBrain ${LNG} ${TST}
#  done
done

less "$WORK_DIR/gen/total_link.perf"

exit 0