11cb0ef41Sopenharmony_ci#!/bin/bash
21cb0ef41Sopenharmony_ci#
31cb0ef41Sopenharmony_ci# Copyright 2015 the V8 project authors. All rights reserved.
41cb0ef41Sopenharmony_ci# Use of this source code is governed by a BSD-style license that can be
51cb0ef41Sopenharmony_ci# found in the LICENSE file.
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ci# Convenience Script used to rank GC NVP output.
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_ciprint_usage_and_die() {
101cb0ef41Sopenharmony_ci  echo "Usage: $0 [OPTIONS]"
111cb0ef41Sopenharmony_ci  echo ""
121cb0ef41Sopenharmony_ci  echo "OPTIONS"
131cb0ef41Sopenharmony_ci  echo  "  -r|--rank new-gen-rank|old-gen-rank    GC mode to profile"
141cb0ef41Sopenharmony_ci  echo  "                                         (default: old-gen-rank)"
151cb0ef41Sopenharmony_ci  echo  "  -s|--sort avg|max                      sorting mode (default: max)"
161cb0ef41Sopenharmony_ci  echo  "  -t|--top-level                         include top-level categories"
171cb0ef41Sopenharmony_ci  echo  "  -c|--csv                               provide csv output"
181cb0ef41Sopenharmony_ci  echo  "  -f|--file FILE                         profile input in a file"
191cb0ef41Sopenharmony_ci  echo  "                                         (default: stdin)"
201cb0ef41Sopenharmony_ci  echo  "  -p|--percentiles                       comma separated percentiles"
211cb0ef41Sopenharmony_ci  exit 1
221cb0ef41Sopenharmony_ci}
231cb0ef41Sopenharmony_ci
241cb0ef41Sopenharmony_ciOP=old-gen-rank
251cb0ef41Sopenharmony_ciRANK_MODE=max
261cb0ef41Sopenharmony_ciTOP_LEVEL=no
271cb0ef41Sopenharmony_ciCSV=""
281cb0ef41Sopenharmony_ciLOGFILE=/dev/stdin
291cb0ef41Sopenharmony_ciPERCENTILES=""
301cb0ef41Sopenharmony_ci
311cb0ef41Sopenharmony_ciwhile [[ $# -ge 1 ]]
321cb0ef41Sopenharmony_cido
331cb0ef41Sopenharmony_ci  key="$1"
341cb0ef41Sopenharmony_ci  case $key in
351cb0ef41Sopenharmony_ci    -r|--rank)
361cb0ef41Sopenharmony_ci      case $2 in
371cb0ef41Sopenharmony_ci        new-gen-rank|old-gen-rank)
381cb0ef41Sopenharmony_ci          OP="$2"
391cb0ef41Sopenharmony_ci          ;;
401cb0ef41Sopenharmony_ci        *)
411cb0ef41Sopenharmony_ci          print_usage_and_die
421cb0ef41Sopenharmony_ci      esac
431cb0ef41Sopenharmony_ci      shift
441cb0ef41Sopenharmony_ci      ;;
451cb0ef41Sopenharmony_ci    -s|--sort)
461cb0ef41Sopenharmony_ci      case $2 in
471cb0ef41Sopenharmony_ci        max|avg)
481cb0ef41Sopenharmony_ci          RANK_MODE=$2
491cb0ef41Sopenharmony_ci          ;;
501cb0ef41Sopenharmony_ci        *)
511cb0ef41Sopenharmony_ci          print_usage_and_die
521cb0ef41Sopenharmony_ci      esac
531cb0ef41Sopenharmony_ci      shift
541cb0ef41Sopenharmony_ci      ;;
551cb0ef41Sopenharmony_ci    -t|--top-level)
561cb0ef41Sopenharmony_ci      TOP_LEVEL=yes
571cb0ef41Sopenharmony_ci      ;;
581cb0ef41Sopenharmony_ci    -c|--csv)
591cb0ef41Sopenharmony_ci      CSV=" --csv "
601cb0ef41Sopenharmony_ci      ;;
611cb0ef41Sopenharmony_ci    -f|--file)
621cb0ef41Sopenharmony_ci      LOGFILE=$2
631cb0ef41Sopenharmony_ci      shift
641cb0ef41Sopenharmony_ci      ;;
651cb0ef41Sopenharmony_ci    -p|--percentiles)
661cb0ef41Sopenharmony_ci      PERCENTILES="--percentiles=$2"
671cb0ef41Sopenharmony_ci      shift
681cb0ef41Sopenharmony_ci      ;;
691cb0ef41Sopenharmony_ci    *)
701cb0ef41Sopenharmony_ci      break
711cb0ef41Sopenharmony_ci      ;;
721cb0ef41Sopenharmony_ci  esac
731cb0ef41Sopenharmony_ci  shift
741cb0ef41Sopenharmony_cidone
751cb0ef41Sopenharmony_ci
761cb0ef41Sopenharmony_ciif [[ $# -ne 0 ]]; then
771cb0ef41Sopenharmony_ci  echo "Unknown option(s): $@"
781cb0ef41Sopenharmony_ci  echo ""
791cb0ef41Sopenharmony_ci  print_usage_and_die
801cb0ef41Sopenharmony_cifi
811cb0ef41Sopenharmony_ci
821cb0ef41Sopenharmony_ciINTERESTING_NEW_GEN_KEYS="\
831cb0ef41Sopenharmony_ci  scavenge \
841cb0ef41Sopenharmony_ci  weak \
851cb0ef41Sopenharmony_ci  roots \
861cb0ef41Sopenharmony_ci  old_new \
871cb0ef41Sopenharmony_ci  semispace \
881cb0ef41Sopenharmony_ci"
891cb0ef41Sopenharmony_ci
901cb0ef41Sopenharmony_ciINTERESTING_OLD_GEN_KEYS="\
911cb0ef41Sopenharmony_ci  clear.dependent_code \
921cb0ef41Sopenharmony_ci  clear.global_handles \
931cb0ef41Sopenharmony_ci  clear.maps \
941cb0ef41Sopenharmony_ci  clear.slots_buffer \
951cb0ef41Sopenharmony_ci  clear.string_table \
961cb0ef41Sopenharmony_ci  clear.weak_collections \
971cb0ef41Sopenharmony_ci  clear.weak_lists \
981cb0ef41Sopenharmony_ci  evacuate.candidates \
991cb0ef41Sopenharmony_ci  evacuate.clean_up \
1001cb0ef41Sopenharmony_ci  evacuate.copy \
1011cb0ef41Sopenharmony_ci  evacuate.update_pointers \
1021cb0ef41Sopenharmony_ci  evacuate.update_pointers.to_evacuated \
1031cb0ef41Sopenharmony_ci  evacuate.update_pointers.to_new \
1041cb0ef41Sopenharmony_ci  evacuate.update_pointers.weak \
1051cb0ef41Sopenharmony_ci  external.mc_prologue \
1061cb0ef41Sopenharmony_ci  external.mc_epilogue \
1071cb0ef41Sopenharmony_ci  external.mc_incremental_prologue \
1081cb0ef41Sopenharmony_ci  external.mc_incremental_epilogue \
1091cb0ef41Sopenharmony_ci  external.weak_global_handles \
1101cb0ef41Sopenharmony_ci  mark.finish_incremental \
1111cb0ef41Sopenharmony_ci  mark.roots \
1121cb0ef41Sopenharmony_ci  mark.weak_closure \
1131cb0ef41Sopenharmony_ci  mark.weak_closure.ephemeral \
1141cb0ef41Sopenharmony_ci  mark.weak_closure.weak_handles \
1151cb0ef41Sopenharmony_ci  mark.weak_closure.weak_roots \
1161cb0ef41Sopenharmony_ci  mark.weak_closure.harmony \
1171cb0ef41Sopenharmony_ci  sweep.code \
1181cb0ef41Sopenharmony_ci  sweep.map \
1191cb0ef41Sopenharmony_ci  sweep.old \
1201cb0ef41Sopenharmony_ci"
1211cb0ef41Sopenharmony_ci
1221cb0ef41Sopenharmony_ciif [[ "$TOP_LEVEL" = "yes" ]]; then
1231cb0ef41Sopenharmony_ci  INTERESTING_OLD_GEN_KEYS="\
1241cb0ef41Sopenharmony_ci    ${INTERESTING_OLD_GEN_KEYS} \
1251cb0ef41Sopenharmony_ci    clear \
1261cb0ef41Sopenharmony_ci    evacuate \
1271cb0ef41Sopenharmony_ci    finish \
1281cb0ef41Sopenharmony_ci    incremental_finalize \
1291cb0ef41Sopenharmony_ci    mark \
1301cb0ef41Sopenharmony_ci    pause
1311cb0ef41Sopenharmony_ci    sweep \
1321cb0ef41Sopenharmony_ci  "
1331cb0ef41Sopenharmony_ci  INTERESTING_NEW_GEN_KEYS="\
1341cb0ef41Sopenharmony_ci    ${INTERESTING_NEW_GEN_KEYS} \
1351cb0ef41Sopenharmony_ci  "
1361cb0ef41Sopenharmony_cifi
1371cb0ef41Sopenharmony_ci
1381cb0ef41Sopenharmony_ciBASE_DIR=$(dirname $0)
1391cb0ef41Sopenharmony_ci
1401cb0ef41Sopenharmony_cicase $OP in
1411cb0ef41Sopenharmony_ci  new-gen-rank)
1421cb0ef41Sopenharmony_ci    cat $LOGFILE | grep "gc=s" \
1431cb0ef41Sopenharmony_ci      | $BASE_DIR/eval_gc_nvp.py \
1441cb0ef41Sopenharmony_ci      --no-histogram \
1451cb0ef41Sopenharmony_ci      --rank $RANK_MODE \
1461cb0ef41Sopenharmony_ci      $CSV \
1471cb0ef41Sopenharmony_ci      $PERCENTILES \
1481cb0ef41Sopenharmony_ci      ${INTERESTING_NEW_GEN_KEYS}
1491cb0ef41Sopenharmony_ci    ;;
1501cb0ef41Sopenharmony_ci  old-gen-rank)
1511cb0ef41Sopenharmony_ci    cat $LOGFILE | grep "gc=ms" \
1521cb0ef41Sopenharmony_ci      | $BASE_DIR/eval_gc_nvp.py \
1531cb0ef41Sopenharmony_ci      --no-histogram \
1541cb0ef41Sopenharmony_ci      --rank $RANK_MODE \
1551cb0ef41Sopenharmony_ci      $CSV \
1561cb0ef41Sopenharmony_ci      $PERCENTILES \
1571cb0ef41Sopenharmony_ci      ${INTERESTING_OLD_GEN_KEYS}
1581cb0ef41Sopenharmony_ci    ;;
1591cb0ef41Sopenharmony_ci  *)
1601cb0ef41Sopenharmony_ci    ;;
1611cb0ef41Sopenharmony_ciesac
162