Commit c80f2bf8 authored by mlippautz's avatar mlippautz Committed by Commit bot

[tools] Beef up GC eval scripts

* Add csv output mode for spreadsheet pasting
* Add option to leave out top-level categories
* Deal with unknown categories

R=hpayer@chromium.org
LOG=N
BUG=
NOTRY=true

Review URL: https://codereview.chromium.org/1846983002

Cr-Commit-Position: refs/heads/master@{#35168}
parent b295462e
...@@ -74,10 +74,11 @@ class Histogram: ...@@ -74,10 +74,11 @@ class Histogram:
class Category: class Category:
def __init__(self, key, histogram): def __init__(self, key, histogram, csv):
self.key = key self.key = key
self.values = [] self.values = []
self.histogram = histogram self.histogram = histogram
self.csv = csv
def process_entry(self, entry): def process_entry(self, entry):
if self.key in entry: if self.key in entry:
...@@ -92,18 +93,29 @@ class Category: ...@@ -92,18 +93,29 @@ class Category:
return max(self.values) return max(self.values)
def avg(self): def avg(self):
if len(self.values) == 0:
return 0.0
return sum(self.values) / len(self.values) return sum(self.values) / len(self.values)
def __str__(self): def __str__(self):
ret = [self.key] if self.csv:
ret.append(" len: {0}".format(len(self.values))) ret = [self.key]
if len(self.values) > 0: ret.append(len(self.values))
ret.append(" min: {0}".format(min(self.values))) ret.append(self.min())
ret.append(" max: {0}".format(max(self.values))) ret.append(self.max())
ret.append(" avg: {0}".format(sum(self.values) / len(self.values))) ret.append(self.avg())
if self.histogram: ret = [str(x) for x in ret]
ret.append(str(self.histogram)) return ",".join(ret)
return "\n".join(ret) else:
ret = [self.key]
ret.append(" len: {0}".format(len(self.values)))
if len(self.values) > 0:
ret.append(" min: {0}".format(self.min()))
ret.append(" max: {0}".format(self.max()))
ret.append(" avg: {0}".format(self.avg()))
if self.histogram:
ret.append(str(self.histogram))
return "\n".join(ret)
def __repr__(self): def __repr__(self):
return "<Category: {0}>".format(self.key) return "<Category: {0}>".format(self.key)
...@@ -143,6 +155,8 @@ def main(): ...@@ -143,6 +155,8 @@ def main():
type=str, nargs='?', type=str, nargs='?',
default="no", default="no",
help="rank keys by metric (default: no)") help="rank keys by metric (default: no)")
parser.add_argument('--csv', dest='csv',
action='store_true', help='provide output as csv')
args = parser.parse_args() args = parser.parse_args()
histogram = None histogram = None
...@@ -154,7 +168,7 @@ def main(): ...@@ -154,7 +168,7 @@ def main():
bucket_trait = LinearBucket(args.linear_histogram_granularity) bucket_trait = LinearBucket(args.linear_histogram_granularity)
histogram = Histogram(bucket_trait, not args.histogram_omit_empty) histogram = Histogram(bucket_trait, not args.histogram_omit_empty)
categories = [ Category(key, deepcopy(histogram)) categories = [ Category(key, deepcopy(histogram), args.csv)
for key in args.keys ] for key in args.keys ]
while True: while True:
......
...@@ -7,47 +7,73 @@ ...@@ -7,47 +7,73 @@
# Convenience Script used to rank GC NVP output. # Convenience Script used to rank GC NVP output.
print_usage_and_die() { print_usage_and_die() {
echo "Usage: $0 RANK SORT [LOGFILE]" echo "Usage: $0 [OPTIONS]"
echo "" echo ""
echo "Arguments:" echo "OPTIONS"
echo " RANK: old-gen-rank | new-gen-rank" echo " -r|--rank new-gen-rank|old-gen-rank GC mode to profile"
echo " SORT: max | avg" echo " (default: old-gen-rank)"
echo " LOGFILE: the file to process. will default to /dev/stdin" echo " -s|--sort avg|max sorting mode (default: max)"
echo " -t|--top-level include top-level categories"
echo " -c|--csv provide csv output"
echo " -f|--file FILE profile input in a file"
echo " (default: stdin)"
exit 1 exit 1
} }
if [[ $# -lt 2 || $# -gt 3 ]]; then OP=old-gen-rank
print_usage_and_die RANK_MODE=max
fi TOP_LEVEL=no
CSV=""
case $1 in LOGFILE=/dev/stdin
new-gen-rank|old-gen-rank)
OP=$1
;;
*)
print_usage_and_die
esac
case $2 in while [[ $# -ge 1 ]]
max|avg) do
RANK_MODE=$2 key="$1"
;; case $key in
*) -r|--rank)
print_usage_and_die case $2 in
esac new-gen-rank|old-gen-rank)
OP="$2"
;;
*)
print_usage_and_die
esac
shift
;;
-s|--sort)
case $2 in
max|avg)
RANK_MODE=$2
;;
*)
print_usage_and_die
esac
shift
;;
-t|--top-level)
TOP_LEVEL=yes
;;
-c|--csv)
CSV=" --csv "
;;
-f|--file)
LOGFILE=$2
shift
;;
*)
break
;;
esac
shift
done
if [ $# -eq 3 ]; then if [[ $# -ne 0 ]]; then
LOGFILE=$3 echo "Unknown option(s): $@"
else echo ""
LOGFILE=/dev/stdin print_usage_and_die
fi fi
GENERAL_INTERESTING_KEYS="\
pause \
"
INTERESTING_NEW_GEN_KEYS="\ INTERESTING_NEW_GEN_KEYS="\
${GENERAL_INTERESTING_KEYS} \
scavenge \ scavenge \
weak \ weak \
roots \ roots \
...@@ -58,8 +84,6 @@ INTERESTING_NEW_GEN_KEYS="\ ...@@ -58,8 +84,6 @@ INTERESTING_NEW_GEN_KEYS="\
" "
INTERESTING_OLD_GEN_KEYS="\ INTERESTING_OLD_GEN_KEYS="\
${GENERAL_INTERESTING_KEYS} \
clear \
clear.code_flush \ clear.code_flush \
clear.dependent_code \ clear.dependent_code \
clear.global_handles \ clear.global_handles \
...@@ -70,8 +94,6 @@ INTERESTING_OLD_GEN_KEYS="\ ...@@ -70,8 +94,6 @@ INTERESTING_OLD_GEN_KEYS="\
clear.weak_cells \ clear.weak_cells \
clear.weak_collections \ clear.weak_collections \
clear.weak_lists \ clear.weak_lists \
finish \
evacuate \
evacuate.candidates \ evacuate.candidates \
evacuate.clean_up \ evacuate.clean_up \
evacuate.copy \ evacuate.copy \
...@@ -85,7 +107,6 @@ INTERESTING_OLD_GEN_KEYS="\ ...@@ -85,7 +107,6 @@ INTERESTING_OLD_GEN_KEYS="\
external.mc_incremental_prologue \ external.mc_incremental_prologue \
external.mc_incremental_epilogue \ external.mc_incremental_epilogue \
external.weak_global_handles \ external.weak_global_handles \
mark \
mark.finish_incremental \ mark.finish_incremental \
mark.prepare_code_flush \ mark.prepare_code_flush \
mark.roots \ mark.roots \
...@@ -94,13 +115,27 @@ INTERESTING_OLD_GEN_KEYS="\ ...@@ -94,13 +115,27 @@ INTERESTING_OLD_GEN_KEYS="\
mark.weak_closure.weak_handles \ mark.weak_closure.weak_handles \
mark.weak_closure.weak_roots \ mark.weak_closure.weak_roots \
mark.weak_closure.harmony \ mark.weak_closure.harmony \
sweep \
sweep.code \ sweep.code \
sweep.map \ sweep.map \
sweep.old \ sweep.old \
incremental_finalize \
" "
if [[ "$TOP_LEVEL" = "yes" ]]; then
INTERESTING_OLD_GEN_KEYS="\
${INTERESTING_OLD_GEN_KEYS} \
clear \
evacuate \
finish \
incremental_finalize \
mark \
pause
sweep \
"
INTERESTING_NEW_GEN_KEYS="\
${INTERESTING_NEW_GEN_KEYS} \
"
fi
BASE_DIR=$(dirname $0) BASE_DIR=$(dirname $0)
case $OP in case $OP in
...@@ -109,6 +144,7 @@ case $OP in ...@@ -109,6 +144,7 @@ case $OP in
| $BASE_DIR/eval_gc_nvp.py \ | $BASE_DIR/eval_gc_nvp.py \
--no-histogram \ --no-histogram \
--rank $RANK_MODE \ --rank $RANK_MODE \
$CSV \
${INTERESTING_NEW_GEN_KEYS} ${INTERESTING_NEW_GEN_KEYS}
;; ;;
old-gen-rank) old-gen-rank)
...@@ -116,9 +152,9 @@ case $OP in ...@@ -116,9 +152,9 @@ case $OP in
| $BASE_DIR/eval_gc_nvp.py \ | $BASE_DIR/eval_gc_nvp.py \
--no-histogram \ --no-histogram \
--rank $RANK_MODE \ --rank $RANK_MODE \
$CSV \
${INTERESTING_OLD_GEN_KEYS} ${INTERESTING_OLD_GEN_KEYS}
;; ;;
*) *)
;; ;;
esac esac
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment